hdu 2608(找规律)

题目链接: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
原文地址:https://www.cnblogs.com/wally/p/3107951.html