分析:
考虑唯一分解定理 \(A\) 可以表示为 \(\prod_{i=1}^{n} p_i^{c_i}\)
约数之和即 \((1+p_1+p_1^2+...+p_1^{c_1})\times(1+p_2+p_2^2+...+p_2^{c_2})\times...\times(1+p_n+p_n^2+...+p_n^{c_n})\)
那么 \(A^B\)可表示为 \(\prod_{i=1}^n p_i^{c_i\times B}\)
此时约数之和即 \((1+p_1+p_1^2+...+p_1^{c_1\times B})\times(1+p_2+p_2^2+...+p_2^{c_2\times B})\times...\times(1+p_n+p_n^2+...+p_n^{c_n\times B})\)
每部分可以等比数列求和 即 \(\prod_{i=1}^n\frac{p_i^{c_i+1}-1}{p_i-1}\) 所以快速幂乘 \(p_i-1\) 的逆元即可
注意到 \(9901\) 是质数 若 \(p_i-1\) 是 \(9901\) 的倍数 逆元会不存在 此时 \(p_i\equiv1\pmod{9901}\)
所以等比数列之和为 \((1+1+1^2+...+1^{c_n\times B+1})=c_n\times B+1\) 答案即 \(\prod_{i=1}^n c_i\times B+1\)
CODE:
点击查看代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define reg register
using namespace std;
typedef long long ll;
const ll Mod=9901,N=1e5+5;
ll A,B,p[N],c[N],tot,ans=1;
void calc(ll x)
{
for(int i=2;i*i<=x;i++)
{
if(x%i==0)
{
p[++tot]=i;
c[tot]=1;
x/=i;
while(x%i==0)
x/=i,c[tot]++;
}
}
if(x>1) p[++tot]=x,c[tot]=1;
}
ll ksm(ll a,ll k)
{
ll res=1;
while(k)
{
if(k&1) (res*=a)%=Mod;
(a*=a)%=Mod;
k>>=1;
}
return res;
}
int main(){
scanf("%lld%lld",&A,&B);
calc(A);
for(int i=1;i<=tot;i++)
{
int a=p[i],k=B*c[i];
((a-1)%Mod==0)?ans=ans%Mod*(k+1)%Mod:ans=ans%Mod*(ksm(a,k+1)%Mod-1+Mod)%Mod*ksm(a-1,Mod-2)%Mod;
}
printf("%lld",ans);
return 0;
}