Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码

Posted by zhjou at 2014-06-08 19:01:36 on Problem 2478
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator