Description
求 \(\sigma_1(A^B)\mod 9901\)
$1\leqslant A,B\leqslant 50000000 $
Solution
\[A=\prod p_i^{q_i}\ \ \ \ \ A^B=\prod p_i^{q^iB}\\
\sigma_1(A^B)=\sigma_1(\prod p_i^{q^iB})=\prod\sigma_1(p_i^{q_iB})\\
\sigma_1(p^q)=\sum_{i=0}^qp^i
\]
然后等比数列求和。
Code
#include<bits/stdc++.h>
using namespace std;
int a,b;
#define MOD 9901
int power(int a,int b)
{
a %= MOD;
int res = 1;
while(b > 0)
{
if(b & 1)res = 1ll * res * a % MOD;
a = 1ll * a * a % MOD;
b = b >> 1;
}
return res;
}
int seq(int a1,int q,long long n)
{
if(n == 0)return 0;
if(n == 1)return a1;
a1 %= MOD;
if(n % 2 == 0)
{
int k = seq(a1,q,n / 2);
return (k + 1ll * k * power(q,n / 2) % MOD) % MOD;
}
else
{
return (a1 + seq(1ll * a1 * q % MOD,q,n - 1)) % MOD;
}
}
int sigma1(int p,long long q)
{//1,p,p^2,...,p^q
return seq(1,p,q + 1);
}
int fac[100000],cnt[100000],tot = 0;
int main()
{
cin >> a >> b;
int k = a;
for(int i = 2;i <= sqrt(k);++i)
{
if(a % i == 0)
{
fac[++tot] = i;
while(a % i == 0)
{
++cnt[tot];
a /= i;
}
}
}
if(a != 1)
{
fac[++tot] = a;
cnt[tot] = 1;
}
//for(int i = 1;i <= tot;++i)cout << fac[i] << " " << cnt[i] << endl;
int ans = 1;
for(int i = 1;i <= tot;++i)
{
ans = 1ll * ans * sigma1(fac[i],1ll * cnt[i] * b) % MOD;
}
cout << ans << endl;
return 0;
}