This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
/**
* 看了其他题解,很多人已经知道是判断是否为完全平方数。 但可能还有人不懂为什么要求完全平方数,可看看我的思路
首先要知道,当一个数因数的个数为奇数时,灯是亮的
一个非完全平方数,因数肯定为偶数 例:8:(1,2,4,8)
一个完全平方数,因数肯定为奇数 例:9:(1,3,9)
其实简单来说非完全平方数的每一个因数都可以跟一个不等自己的数相乘得到这个非完全平方数(18,24);所以因数一定是偶数
完全平方数其中一个因数乘自己可得到这个完全平方数(19,33);所以因数一定是奇数;
* @return
*/
int main(){
long long n;cin>>n;
for(int i=1;i*i<=n;i++)//i是中间数,我不用sqrt是为了少写个文件头
cout<<i*i<<" ";//输出的全是完全平方数
}