/* LightOJ 1336 Sigma Function http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1336 数论 奇偶性 题目求f(n)为偶数的个数 我们发现如果f(n)为奇数,则n为x^2,2*x^2,2^x三种形式, 因为2^x中已经包含剩下两种, 所以只需求x^2和2*x^2的个数即可求得答案。 * 打了半天表发现没用233333 * */ #include <cstdio> #include <algorithm> using namespace std; int main() { //freopen("a.in","r",stdin); int t; scanf("%d",&t); long long n; int j=1; while(t--) { scanf("%lld",&n); long long ans=0; for(long long i=1;i*i<=n;i++) { if(2*i*i<=n) ans++; ans++; } ans=n-ans; printf("Case %d: %lld\n",j,ans); j++; } return 0; } //打表 /*#include <cstdio>*/ //#include <algorithm> //using namespace std; //const int Nmax=10001; //int prime[Nmax]; //int is_prime[Nmax]; //int cnt; //int m[Nmax]; //int times[Nmax]; //int num; //void get_prime() //{ //for(int i=2;i<Nmax;i++) //is_prime[i]=1; //for(int i=2;i<Nmax;i++) //{ //if(is_prime[i]) //{ //prime[++cnt]=i; //for(int j=2;j*i<Nmax;j++) //is_prime[i*j]=0; //} //} //} //int pow(int base,int n) //{ //int ans=1; //while(n>0) //{ //if(n&1) //ans*=base; //base*=base; //n>>=1; //} //return ans; //} //int check() //{ //for(int i=1;i<=num;i++) //{ //int a=pow(m[i],times[i]+1)-1; //int b=m[i]-1; //a/=b; //if(!(a&1)) //return 1; //} //return 0; //} //void get(int n) //{ //num=0; //int i=1; //while(prime[i]*prime[i]<=n) //{ //if(n%prime[i]==0) //{ //++num; //times[num]=0; //m[num]=prime[i]; //} //while(n%prime[i]==0) //{ //n/=prime[i]; //times[num]++; //} //i++; //} //if(n!=1) //{ //++num; //times[num]=1; //m[num]=n; //} //} //void print(int n) //{ //int ans=0; //for(int i=2;i<=n;i++) //{ //get(i); //ans+=check(); //} //printf("%d:%d\n",n,ans); //} //int main() //{ //get_prime(); //for(int n=1;n<=1000;n++) //{ //print(n); //} //return 0; /*}*/
时间: 2024-10-18 11:37:38