标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2673 Accepted Submission(s): 1123
#include<stdio.h> #include<string.h> int el(int n) { int i; int ans=n; for(i=2;i*i<=n;i++)//用i*i是为了提高运算效率 { if(n%i==0) ans=ans/i*(i-1); while(n%i==0) n/=i; } if(n>1)//为了避免没有运算到1的情况 ans=ans/n*(n-1); return ans; } int main() { int n,m,j,i; while(scanf("%d",&m),m) { printf("%d\n",m-el(m)-1); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4802323.html