#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; }
时间: 2024-10-12 16:38:14