标签:mit tle strong i++ amp include iss ssi input
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13024 Accepted Submission(s): 6941
1 int eular(int n) 2 { 3 int ret=1,i; 4 for(i=2;i*i<=n;i++) 5 { 6 if(n%i==0) 7 { 8 n/=i,ret*=i-1; 9 while(n%i==0) 10 { 11 n/=i,ret*=i; 12 } 13 } 14 } 15 if(n>1) ret*=n-1; 16 return ret;
这道题的题解:
1 #include<stdio.h> 2 int eular(int n) 3 { 4 int ret=1,i; 5 for(i=2;i*i<=n;i++) 6 { 7 if(n%i==0) 8 { 9 n/=i,ret*=i-1; 10 while(n%i==0) 11 { 12 n/=i,ret*=i; 13 } 14 } 15 } 16 if(n>1) ret*=n-1; 17 return ret; 18 } 19 int main () 20 { 21 int a,n,s; 22 scanf("%d",&a); 23 while(a--) 24 { 25 scanf("%d",&n); 26 s=eular(n); 27 printf("%d\n",s); 28 } 29 return 0; 30 }
标签:mit tle strong i++ amp include iss ssi input
原文地址:http://www.cnblogs.com/lyf0031/p/7204711.html