kaideng

题目描述

首先所有的灯都是关的(注意是关!),编号为1的人走过来,把是一的倍数的灯全部打开,编号为二的的把是二的倍数的灯全部关上,编号为3的人又把是三的倍数的灯开的关上,关的开起来……直到第N个人为止。

给定N,求N轮之后,还有哪几盏是开着的。

1<=N<=2^40

https://www.luogu.org/problem/show?pid=1876

//只有完全平方数的因子个数为奇数个,最后才是开着的 
#include<iostream> 
#include<cstdio>
#include<cstring> 
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
#define LL long long 
using namespace std;
LL n;
int main()
{
    scanf("%lld",&n);
    LL p=1;
    while(p*p<=n)
    {
        printf("%lld ",p*p);
        p++;
    }
    return 0;
} 
原文地址:https://www.cnblogs.com/dfsac/p/7587943.html