标签:blog io os sp for on 2014 log cti
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <queue> #include <cmath> #include <stack> #include <map> #include <ctime> #include <iomanip> #pragma comment(linker, "/STACK:1024000000"); #define EPS (1e-6) #define LL long long #define ULL unsigned long long #define _LL __int64 #define INF 0x3f3f3f3f #define Mod 1000000007 using namespace std; int p; unsigned euler(unsigned x) { unsigned i,res=x; for(i=2;i<(int)sqrt(x*1.0)+1;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; } int main() { while(scanf("%d",&p)!=EOF) { printf("%d\n",euler(p-1)); } return 0; }
POJ 1284 Primitive Roots 欧拉函数模板题
标签:blog io os sp for on 2014 log cti
原文地址:http://blog.csdn.net/zmx354/article/details/41084717