Cod sursa(job #2113024)

Utilizator n.nadim2001Nofal Nadim n.nadim2001 Data 24 ianuarie 2018 10:33:59
Problema Suma divizorilor Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <fstream>

using namespace std;

ifstream fin ("sumdiv.in");
ofstream fout ("sumdiv.out");
typedef  unsigned long long ULL;
int MOD=9901;

void EuclidE(int a,int b,int& x,int& y,int& d)
{
    if(b==0){x=1;y=0;d=a;}
    else{int x0, y0;
         EuclidE(b,a%b,x0,y0,d);
         x=y0;y=x0-a/b*y0;
        }
}



ULL put(ULL a,ULL b)
{
    if(b==0)return 1;
    if(b==1)return a;
    ULL aux=put(a,b/2);
    if(b&1)return ((aux*aux)%MOD*a)%MOD;
    return (aux*aux)%MOD;
}

ULL a,b,n=1,s=1,k;
int i,d,p,x,y,z;
int main()
{
    fin>>a>>b;
    n=a;

    d=2;
    while(n>1)
    { p=0;
      while(n%d==0){n=n/d;
                    ++p;}
      if(p){EuclidE(MOD,d-1,x,y,z);

            k=((put(d,b*p+1)-1)*y)%MOD;

            s*=(s*k)%MOD;
           }
      ++d;
      if(d*d>n)d=n;
    }
    if(s<0)s=s+MOD;
    fout<<s;

    fin.close(); fout.close();
    return 0;
}