loj1336 (mathematics)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.