码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ 4173: 数学

时间:2017-10-06 16:57:24      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:share   namespace   content   comment   space   text   注意   string   return   

【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 }

 

BZOJ 4173: 数学

标签:share   namespace   content   comment   space   text   注意   string   return   

原文地址:http://www.cnblogs.com/fengzhiyuan/p/7631731.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!