题目描述
Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).
输入描述:
The only line contains the two natural numbers A and B, (0 <= A,B <= 50000000)separated by blanks.
输出描述:
The only line of the output will contain S modulo 9901.

思路
1.质因数分解,就是将一个数分解成为 图片说明
2.唯一分解定律,就是字面意思
3.约数和公式,如下文所示
图片说明
图片说明
然后呢我们可以通过分类以及乘法中的提取公因式法,将sum函数中a为奇数的公式和sum函数中a为偶数的公式推出..

完整AC代码:

#include <iostream>

using namespace std;

const int mod = 9901;

int ksm(int a, int b) {
    int res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}

int sum(int p, int k) {
    if (k == 0) return 1;
    if (k % 2 == 0) return (p % mod * sum(p, k - 1) + 1) % mod;
    return (1 + ksm(p, k / 2 + 1)) * sum(p, k / 2) % mod;
}

int main() {
    ios::sync_with_stdio;

    int A, B;
    cin >> A >> B;

    int res = 1;
    for (int i = 2; i <= A; i++) {
        int s = 0;
        while (A % i == 0) {
            s++;
            A /= i;
        }
        if (s) res = res * sum(i, s * B) % mod;
    }
    if(!A) res=0;
    cout << res << endl;
    return 0;
}