BZOJ 4173: 数学

【bzoj4173】数学

Description

 

Input

 输入文件的第一行输入两个正整数 。

Output

 如题

Sample Input

5 6

Sample Output

240

HINT

 N,M<=10^15

 

证明还是比较靠谱的。

嗯嗯

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 #include<cstdlib>
 5 #include<algorithm>
 6 
 7 using namespace std;
 8 
 9 typedef long long ll;
10 const ll mod=998244353;
11 
12 ll n,m;
13 ll phi(ll n)
14 {
15     ll ans=n,sq=(ll)sqrt(n);
16     for (int i=2;i<=sq;i++)
17     if (n%i==0)
18     {
19         ans=ans/i*(i-1);
20         while (n%i==0) n=n/i;
21     }
22     if (n>1) ans=ans/n*(n-1);
23     return ans%mod;
24 }
25 int main()
26 {
27     int x;
28     scanf("%lld%lld",&n,&m);
29     ll ans=phi(n)*phi(m)%mod*(n%mod)%mod*(m%mod)%mod;//这里mod要强烈注意,里面mod,外面也要mod!!!!!
30     printf("%lld",ans);
31 }

 

posted @ 2017-10-06 16:32  Kaiser-  阅读(129)  评论(0编辑  收藏  举报