标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2874 Accepted Submission(s): 1240
#include <stdio.h> #include <string.h> using namespace std; typedef long long LL; LL phi(LL x) { LL ans=x; for(LL i=2; i*i<=x; i++) if(x%i==0) { ans=ans/i*(i-1); while(x%i==0) x/=i; } if(x>1) ans=ans/x*(x-1); return ans; } int main(){ LL n; while(scanf("%lld",&n)!=EOF,n){ printf("%lld\n",n-phi(n)-1); } }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5540481.html