题目: 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;
}
本文解析了HDU-6265 MasterofPhi问题,通过使用欧拉函数解决数学问题。代码中实现了快速幂运算,利用欧拉函数计算特定数值,并在循环中更新最终结果。
883

被折叠的 条评论
为什么被折叠?



