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

Re:为什么单独求欧拉函数就对了,用递推求欧拉函数就RE了呢?

Posted by jk10171101 at 2012-07-11 14:40:26 on Problem 1284
In Reply To:为什么单独求欧拉函数就对了,用递推求欧拉函数就RE了呢? Posted by:jk10171101 at 2012-07-11 14:39:13
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn=70000;
__int64 phi[maxn];
int main()
{
    int n,i,j;
    for(i=1;i<=maxn;i++)
     phi[i]=i;
    for(i=2;i<=maxn;i+=2)
      phi[i]/=2;
     for(i=3;i<=maxn;i+=2)
       if(phi[i]==i)
         for(j=i;j<=maxn;j+=i)
             phi[j]=phi[j]/i*(i-1);
    while(cin>>n){
        cout<<phi[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