标签:
题目链接:http://poj.org/problem?id=2407
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 13599 | Accepted: 6772 |
Description
Input
Output
Sample Input
7 12 0
Sample Output
6 4
Source
#include <stdio.h> int Euler(int n) { int ans = n; for(int i=2;i*i<=n;i++) { if(n%i==0) { n/=i; ans = ans - ans/i; while(n%i==0) { n/=i; } } } if(n>1) ans = ans - ans/n; return ans; } int main() { int n; while(scanf("%d",&n),n) { printf("%d\n",Euler(n)); } return 0; }
#include <stdio.h> int Euler(int n) { int res = n; for(int i=2; i*i<=n; i++) { if(n%i==0) { n=n/i; res = res - res/i; while(n%i==0) n/=i; } } if(n>1) res = res - res/n; return res; } int main() { int cases; scanf("%d",&cases); int ans[10005]; ans[1] = 2; for(int i=2; i<=10000; i++) { ans[i]=ans[i-1]+Euler(i); } while(cases--) { int t,k; scanf("%d%d",&t,&k); printf("%d %d\n",t,ans[k]); } return 0; }
Poj(2407),Greater New York Regional 2015 (D)
标签:
原文地址:http://www.cnblogs.com/TreeDream/p/5781830.html