标签:targe get who lamp include color inf cpp namespace
Consider the second test case The initial condition : 0 0 0 0 0 … After the first operation : 1 1 1 1 1 … After the second operation : 1 0 1 0 1 … After the third operation : 1 0 0 0 1 … After the fourth operation : 1 0 0 1 1 … After the fifth operation : 1 0 0 1 0 … The later operations cannot change the condition of the fifth lamp any more. So the answer is 0.
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n,ans;
while (cin >> n) {
ans = 2;
if (n <= 3)cout<<1<<endl;
else {
for (int i = 2; i*i<= n; i++) { //枚举含有几个因子
if (n%i == 0) {
if (i*i == n)ans++; //
else ans += 2; //如果不是i*i,那除了i是因子,n/i也是,所以上边枚举到i*i就可以了。
}
}
if (ans & 1)cout<<1<<endl;
else cout<<0<<endl;
}
}
return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
double n,ans;
while (cin >> n) {
int ans=0;
for(int i=1;i<400;i++){ //400*400就大于1e5了
if(i*i==n)ans=1;
}
if(ans)cout<<"1\n";
else cout<<"0\n";
}
return 0;
}
标签:targe get who lamp include color inf cpp namespace
原文地址:https://www.cnblogs.com/52dxer/p/10548007.html