我不明白为什么WA了#14
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int M = 9901;
LL a, b;
map<LL, LL> m;
void fun(LL n)
{
for (int i = 2; i <= sqrt(n); i++)
while (n % i == 0)
{
m[i]++;
n /= i;
}
if (n > 1)
m[n]++;
}
LL f(LL a, LL b)
{
LL ans = 1;
while (b)
{
if (b % 2 == 1)
ans = ans * a % M;
a = a * a % M;
b /= 2;
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> a >> b;
fun(a);
LL ans = 1;
for (map<LL, LL>::iterator it = m.begin(); it != m.end(); it++)
{
LL p = it->first, c = it->second;
c *= b;
if ((p - 1) % M != 0)
{
LL x = f(p, c + 1) - 1, y = f(p - 1, M - 2);
ans = ans * x % M * y % M;
}
else
ans = ans * (c + 1) % M;
}
cout << ans;
return 0;
}