标签:
Description
Input
Output
Sample Input
2 25608 24027
Sample Output
7680 16016
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<queue> #include<stack> #include<cmath> using namespace std; #define INF 0x3f3f3f3f #define maxn 2100 int Euler(int x) { int i,res = x; for(i = 2;i*i<=x;i++) { if(x%i==0) res = res/i*(i-1); while(x%i==0) x/=i; } if(x>1) res = res / x*(x-1); return res; }//欧拉函数,寻找从1到n与n互质的数 int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",Euler(n)); } return 0; }
标签:
原文地址:http://www.cnblogs.com/biu-biu-biu-/p/5731513.html