Master of Phi(极性函数+欧拉函数)
题目: Master of Phi
思路:参考博客:HDU-6265 Master of Phi (数论)
欧拉函数内容:
代码:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL a[60], b[60];
const LL mod = 998244353;
LL q_pow(LL a, LL b)
{
LL ans = 1;
while(b)
{
if(b & 1)ans = (ans*a)%mod;
a = (a*a)%mod;
b >>= 1;
}
return ans;
}
int main()
{
int T, n;
cin>>T;
while(T--)
{
cin>>n;
for(int i = 1; i <= n; i++)
{
cin>>a[i]>>b[i];
}
LL mu = 1;
for(int i = 1; i <= n; i++)
{
LL t = q_pow(a[i], b[i]-1);
mu = (mu * t)%mod;
t = (a[i]%mod + (a[i]*b[i])%mod-b[i]%mod+mod)%mod;
mu = (mu * t)%mod;
}
cout<<mu<<endl;
}
return 0;
}