标签:phi void col color class break code ++ lse
1 const int maxn = 10000000 + 5; 2 int n,tot; 3 LL S[maxn]; 4 LL pri[maxn],phi[maxn]; 5 LL ans; 6 void Phi() 7 { 8 phi[1]=1; 9 for(int i=2;i<=n;i++) 10 { 11 if(!phi[i]){phi[i]=i-1;pri[++tot]=i;} 12 for(int j=1;j<=tot;j++) 13 { 14 int x=pri[j]; 15 if(i*x>n)break; 16 if(i%x==0){phi[i*x]=phi[i]*x;break;} 17 else phi[i*x]=phi[i]*phi[x]; 18 } 19 } 20 }
突然发现欧拉函数好强啊!!!
标签:phi void col color class break code ++ lse
原文地址:https://www.cnblogs.com/transcendent-heming/p/11776249.html