Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
贴代码#include <iostream> #define N 1000001 using namespace std; long long a[N],n,i,j; int main() { for(i=1;i<N;i++)a[i]=i%2?i:i/2; for(i=3;i<N;i+=2) if(a[i]==i) for(j=i;j<N;j+=i) a[j]=a[j]-a[j]/i; for(i=3;i<N;i++) a[i]+=a[i-1]; while(cin>>n&&n) cout<<a[n]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator