Cod sursa(job #3150648)

Utilizator SerbanCaroleSerban Carole SerbanCarole Data 17 septembrie 2023 20:22:12
Problema Suma divizorilor Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <fstream>
#define pb push_back
using namespace std;
using pii = pair<int,int>;
ifstream cin("sumdiv.in");
ofstream cout("sumdiv.out");
const long long m = 9901;
long long a , b;
long long fastpow( long long x , long long y )
{
    if(!y) return 1LL;
    if(y&1) return (x*fastpow(x,y-1))%m;
    int p = fastpow(x,y/2);
    return (p*p)%m;
}
signed main(){
    cin >> a >> b;
    long long ans = 1;
    for(int i = 2 ; a > 1 && i * i <= a ; i++)
    {
        if(a%i) continue;
        long long hm = 0,num;
        while(a%i==0)
        {
            ++hm;
            a/=i;
        }
        num = fastpow(i,hm*b);
        num = (num*i)%m;
        ans = (ans*((num-1)*fastpow(i-1,m-2))%m)%m;
    }
    if(a > 1)
    {
        long long nr = fastpow(a,b);
        ans = (ans*((nr*a-1)%m*fastpow(a-1,m-2)))%m;
    }
    cout << ans;
    return 0;
}