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:我也是这样子。。后来人注意。。。

Posted by jiqiujia at 2013-07-20 16:14:35 on Problem 2478
In Reply To:什么原因??C++交RE,然后G++交就AC!!!!附代码,求解??? Posted by:crazy852456 at 2012-07-16 23:28:16
> #include<iostream>
> #include<string.h>
> #define maxn 1000010
> using namespace std;
> 
> int phi[maxn];
> long long f[maxn];
> void euler()
> {
>     int 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);
>             }
>         }
> }
> void fun()
> {
>     int i;     
>     euler();
>     memset(f,0,sizeof(f)); 
>     f[2]=1; 
>     for(i=3;i<=maxn;i++) 
>         f[i]=f[i-1]+phi[i];
> }
> int main()
> {
>     int n;
>     fun();    
>     while(cin>>n&&n)
>     {         
>         cout<<f[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