Portal: Sigma Function
Test instructions: Defines the sum of the approximate sum of n for f (n), which is the number of even numbers in the F value in [1,n].
Analysis: By the question given the formula, if f (n) is an odd number, then each item multiplied must be an odd number.
Each item is an odd number of conditions:
(1) If pi=2, then Pi^0+pi^1+......pi^ei will be odd;
(2) If Pi is an odd prime number, then only pi^0+pi^1+......pi^ei is odd if ei is even.
So Dfs goes on to count the number of F (n) as odd, since F (n) is less odd.
#pragmaComment (linker, "/stack:1024000000,1024000000")#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<limits.h>#include<iostream>#include<algorithm>#include<queue>#include<cstdlib>#include<stack>#include<vector>#include<Set>#include<map>#defineLL Long Long#defineMoD 100000000#defineINF 0x3f3f3f3f#defineEPS 1e-6#defineN 1000000#defineLson l,m,rt<<1#defineRson m+1,r,rt<<1|1#definePII pair<int,int>using namespacestd;inline LL Read () {CharCh=getchar (); LL x=0, f=1; while(ch>'9'|| ch<'0'){if(ch=='-') f=-1; ch=GetChar ();} while(ch<='9'&&ch>='0') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}BOOLvis[n+5];intprime[n/Ten],tot;voidinit () {memset (Vis,false,sizeof(VIS)); Tot=0; for(intI=2; i<=n;i++) { if(!Vis[i]) {Prime[tot++]=i; } for(intj=0; j<tot&&i*prime[j]<=n;j++) {vis[i*prime[j]]=true; if(i%prime[j]==0) Break; }}}ll N,ans;voidDFS (LL dep,ll x) {ans++; for(inti=dep;i<tot;i++) { if(i==0) { if(x*2<=n) DFS (i,x*2); Else return; } Else{LL temp= (LL) prime[i]*Prime[i]; if(x*temp<0)return;//the overflow of the pit Daddy if(x*temp<=n) DFS (i,x*temp); Else return; } }}intMain () {intt,cas=1; Init (); T=read (); while(t--) {n=read (); Ans=0; DFS (0,1); printf ("Case %d:%lld\n", cas++,n-ans); }}View Code
loj1336 (mathematics)