标签:style blog io color os for sp div on
#include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #include<queue> #include<cmath> using namespace std; const int Max=100010; bool IsPrime[Max]; int NumPrime[Max],phi[Max]; int N,Top=0; int main() { scanf("%d",&N); for(int i=1;i<=N;i++) IsPrime[i] = true ; IsPrime [1] = false;Top = 0; for(int i=2;i<=N;i++) { if(IsPrime[i]){ NumPrime[++Top] = i;phi[i]=i-1;} for(int j=1;j<=Top && i*NumPrime[j]<=N;j++) { IsPrime[i*NumPrime[j]] = false; if(i % NumPrime[j]==0) { phi[i * NumPrime[j] ] = NumPrime[j] * phi [i]; break; } else phi[ i * NumPrime[j] ] = phi[NumPrime[j]] * phi[i]; } } cout<<phi[100]<<endl; }
标签:style blog io color os for sp div on
原文地址:http://www.cnblogs.com/coutendl/p/4077407.html