| ||||||||||
| 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 | |||||||||
GCD迅速水过#include<iostream>
using namespace std;
int gcd(int i,int j)
{
int k;
while(i%j)
{
k=j;
j=i%j;
i=k;
}
return j;
}
int main()
{
int n,k=1,i,a[1001];
a[1]=3,a[2]=5;
for(n=3;n<=1000;n++)
{
for(i=1;i<n;i++)
if(gcd(n,i)==1)k++;
a[n]=k*2+3;
}
cin>>n;
for(i=0;i<n;i++)
{
cin>>k;
cout<<i+1<<" "<<k<<" "<<a[k]<<endl;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator