面向题意编程。。
#include<bits/stdc++.h> using namespace std; typedef long long LL; int cal(int n) { int ret=1; for(int i=2;i*i<=n;i++) if(n%i==0) { int cnt=0; while(n%i==0) { n/=i; cnt++; if(cnt>1) return 0; } ret=-ret; } if(n>1) ret=-ret; return ret; } int main() { int n; while(cin>>n) cout<<cal(n)<<endl; }