hdu 2608(找规律)

来源:互联网 发布:python def的作用 编辑:程序博客网 时间:2024/05/20 12:50

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2608

思路:T[n]为1时当且仅当n为某数的平方或者是某数平方的2倍。

 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 typedef long long LL; 8  9 int main(){10    int _case,n,ans,k;11    scanf("%d",&_case);12    while(_case--){13       scanf("%d",&n);14       ans=k=(int)sqrt(n*1.0);15       for(LL i=1;i<=k;i++)if(i*i*2<=n)ans++;16       printf("%d\n",ans%2);17    }18    return 0;19 }
View Code

 

0 0