网站后台选项卡效果,云南省工程建设造价协会网站,曹健的wordpress博客,亚洲tv欧拉函数的定义 1∼N1∼N 中与 NN 互质的数的个数被称为欧拉函数#xff0c;记为 ϕ(N)ϕ(N)。 若在算数基本定理中#xff0c;Npa11pa22…pammNp1a1p2a2…pmam#xff0c;则#xff1a; ϕ(N)ϕ(N) Np1−1p1p2−1p2…pm−1pm 代码#xff1a;
#includeiostream记为 ϕ(N)ϕ(N)。 若在算数基本定理中Npa11pa22…pammNp1a1p2a2…pmam则 ϕ(N)ϕ(N) N×p1−1p1×p2−1p2×…×pm−1pm 代码
#includeiostream
using namespace std;
int n;int main(){scanf(%d,n);while(n--){int x;scanf(%d,x);int resx;for(int i2;ix/i;i){if(x%i0){res res/i * (i-1);while(x%i0) x/i;}}if(x1) res res/x * (x-1);printf(%d\n,res);}}