异想之旅 @ 2022-01-30 23:18:59
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 9901;
map<int, int> ys;
long long ksm(long long x, long long y) {
if (y == 0) return 1;
if (y % 2 == 0) return ((long long)pow(ksm(x, y / 2) % mod, 2) % mod);
return (x * (long long)pow(ksm(x, y / 2) % mod, 2) % mod);
}
int main() {
int a, b;
cin >> a >> b;
int aa = a;
ys[2] = 0;
while (a % 2 == 0) {
a /= 2;
ys[2]++;
}
ys[2] *= b;
for (int i = 3; i <= a; i += 2) {
ys[i] = 0;
while (a % i == 0) {
a /= i;
ys[i]++;
}
ys[i] *= b;
}
long long ans = 1, t = ksm(aa, b);
for (int i = 2; i <= t; i++) {
if (!ys[i]) continue;
int temp;
if (i % mod == 1) {
temp = ys[i] + 1;
} else
temp = ((ksm(i, ys[i] + 1) + mod - 1) % mod) *
ksm(i - 1, mod - 2) % mod;
if (temp != 0) ans = ans * temp % mod;
}
cout << ans << endl;
return 0;
}
若能指出问题有重谢!
by 异想之旅 @ 2022-01-30 23:34:24
找到问题了,for循环的界限t可能会超long long……