And about the number of

Calculation known positive integer \ (A \) divisors and method are:

The \ (A \) prime factor decomposition \ (p_1 ^ {c_1} p_2 ^ {c_2} p_3 ^ {c_3} \ cdots p_m ^ {c_m} \)

\ (A \) about the number and is the \ ((1 + p_1 + p_1 ^ 2 + \ cdots + p_1 ^ {c_1}) * (1 + p_2 + p_2 ^ 2 + \ cdots + p_2 ^ {c_2}) * (1 + p_2 + p_2 ^ 2 + \ cdots + p_2 ^ {c_2}) * \ cdots * (1 + p_m + p_m ^ 2 + \ cdots + p_m ^ {c_m}) \)

I remember Li Yudong gave a geometric series summation points method of treatment seeking, probably will use the series is geometric, the use of a shorter series of long and determined the number of columns and the concrete realization there are some details.


#include<bits/stdc++.h>
using namespace std;

#define int long long

const int mod = 9901;

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

int sum(int p, int c)
{
    if(c == 1) return 1;
    int smer = sum(p, c>>1);
    int now = (smer + smer * ksm(p, c>>1) % mod) % mod;
    if(c&1) now = (now + ksm(p, c-1)) % mod;
    return now % mod;
}

signed main()
{
    
    int a, b; cin >> a >> b;
    
    if(!a)
    {
        cout << 0;
        return 0;
    }
    
    int ans = 1;
    for(int i=2; i<=a; ++i)
    {
        int s = 0;
        while(a%i == 0) ++s, a/=i;
        ans = ans * sum(i, s * b + 1) % mod;
    }
    
    cout << ans % mod;
    return 0;
    
}

Guess you like

Origin www.cnblogs.com/tztqwq/p/12238758.html