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:17:54 on Problem 3090
#include <iostream>
#define N 1001
using namespace std;
int a[N],n,i,j,t;
int main(int argc, char *argv[])
{
    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=2;i<N;i++) a[i]+=a[i-1];
    cin>>t;
    for(i=1;i<=t;i++)
    {cin>>n;cout<<i<<" "<<n<<" "<<2*a[n]+1<<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