Cod sursa(job #2931048)

Utilizator anastasiadumitru3Dumitru Anastasia anastasiadumitru3 Data 30 octombrie 2022 13:38:46
Problema Suma divizorilor Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <iostream>
#include <fstream>

using namespace std;
# define Mod 9901
int putere(int a, int n){
    if(n%2==0)
        return((long long )( putere(a,n/2)% Mod)*(putere(a,n/2)% Mod))%Mod;
    else if(n%2==1 && n!=1)
        return (((long long )(putere(a,n/2)%Mod)*(putere(a,n/2)%Mod))%Mod*(a%Mod))%Mod;
    else return a%Mod;

}

int main()
{
    ifstream in("sumdiv.in");
    ofstream out("sumdiv.out");
    int n, a, i, b, p, d, x, y;
    long long s=1, e, nr;
    in>>a>>b;
    p=2;
    while(p*p<=a){
        e=0;
        if(a%p==0){
        while (a%p==0){
            a=a/p;
            ++e;
        }
       e*=b;
       x=putere(p-1, Mod-2);
          nr=putere(p, e+1)%Mod-1;
          nr+=Mod;
          nr%=Mod;
          s*=((long long)x*nr)%Mod;
        }
        ++p;
    }
    if(a>1){
        x=putere(a-1, Mod-2);
        x+=Mod;
        x%=Mod;
          nr=putere(a, b+1)%Mod-1;
          nr+=Mod;
          nr%=Mod;
        //  cout<<x;
          s*=((long long)x*nr)%Mod;
    }
    out<<s;
    return 0;
}