Cod sursa(job #2931036)

Utilizator magicninjaJula Diana magicninja Data 30 octombrie 2022 13:25:40
Problema Suma divizorilor Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
ifstream in("sumdiv.in");
ofstream out("sumdiv.out");

int mod = 9901;

int plog(int n, int p){
  int rez = 1;
  while(p > 0){
        if(p % 2 == 1){
            rez = rez * n % mod;
        }
        n = n * n % mod;
        p = p / 2;
    }
    return rez;
}

int main()
{
    long long d = 2, n, p, e, s = 1;
    in >> n >> p;
    while(n > 1){
        e = 0;
        while(n % d == 0){
            e++;
            n /= d;
        }
        if(e > 0){
            d = d % mod;
            plog(d, e * p + 1);
            s = s * ((plog(d, e * p + 1) - 1) / (d - 1)) % mod;
            s = s % mod;
        }
    }
    out << s;
    return 0;
}