| ||||||||||
| 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 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator