首页 > 代码库 > bzoj4173 -- 欧拉函数

bzoj4173 -- 欧拉函数

 题解:http://blog.csdn.net/PoPoQQQ/article/details/46820313

 

代码:

技术分享
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cmath>
 6 using namespace std;
 7 #define M 998244353
 8 #define ll long long
 9 ll n,m;
10 inline ll Phi(ll x){
11     ll Ans=x;
12     for(ll i=2;i*i<=x;i++)
13     if(x%i==0){
14         Ans/=i;Ans*=i-1;
15         x/=i;
16         while(x%i==0)x/=i;
17     }
18     if(x!=1)Ans/=x,Ans*=(x-1);
19     return Ans%M;
20 }
21 int main(){
22     scanf("%lld%lld",&n,&m);
23     printf("%lld\n",Phi(n)*Phi(m)%M*(n%M)%M*(m%M)%M);
24     return 0;
25 }
bzoj4173

 

bzoj4173 -- 欧拉函数