标签:get pow logs ash pac names div targe dac
#include<bits/stdc++.h> using namespace std; const int maxn = 1e7; int p1(int n)//单值 O(根号n) { int res = n; for(int i=2;i*i<=n;i++) { if(n%i == 0) { res = res /i * (i-1); for(;n%i==0;n/=i); } } if(n != 1) res = res/n*(n-1); return res; } int p[maxn]; void p2() //O(maxn)时间筛出欧拉函数的值 { for(int i=0;i<maxn;i++) p[i] =i; for(int i=2;i<maxn;i++) { if(p[i] == i) for(int j=i;j<maxn;j+=i) p[j] = p[j]/i*(i-1); } } int main() { int n; scanf("%d",&n); printf("%d\n",p1(n)); }
标签:get pow logs ash pac names div targe dac
原文地址:http://www.cnblogs.com/Draymonder/p/7381064.html