Bzoj4173 数学

Posted by yjjr's blog on February 6, 2018

标签:欧拉函数,数学,数论

Description

 

Input

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

Output

 如题

Sample Input

5 6

Sample Output

240

HINT

 N,M<=10^15

 

直接放PoPoQ大爷的式子

http://blog.csdn.net/popoqqq/article/details/46820313

code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define rep(i,a,b) for(LL i=a;i<=b;i++)
#define dep(i,a,b) for(LL i=a;i>=b;i--)
#define LL long long
#define mem(x,num) memset(x,num,sizeof x)
using namespace std;
const LL mod=998244353;
LL n,m;
LL phi(LL n)
{
	LL t=n;
	rep(i,2,sqrt(n))
	    if(n%i==0){
			t=t/i*(i-1);
			while(n%i==0)n/=i;
		}
	if(n!=1)t=t/n*(n-1);
	return t;
}

int main()
{
	cin>>n>>m;
	cout<<(phi(n)%mod)*(phi(m)%mod)%mod*(n%mod)%mod*(m%mod)%mod<<endl;
	return 0;
}


本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr