Files
python/LuoGu/RuMen/P1876.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

17 lines
919 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
/**
* 看了其他题解,很多人已经知道是判断是否为完全平方数。 但可能还有人不懂为什么要求完全平方数,可看看我的思路
首先要知道,当一个数因数的个数为奇数时,灯是亮的
一个非完全平方数,因数肯定为偶数 例8:1,2,4,8
一个完全平方数,因数肯定为奇数 例9:1,3,9
其实简单来说非完全平方数的每一个因数都可以跟一个不等自己的数相乘得到这个非完全平方数18,24所以因数一定是偶数
完全平方数其中一个因数乘自己可得到这个完全平方数1933所以因数一定是奇数
* @return
*/
int main(){
long long n;cin>>n;
for(int i=1;i*i<=n;i++)//i是中间数我不用sqrt是为了少写个文件头
cout<<i*i<<" ";//输出的全是完全平方数
}