Cod sursa(job #2332738)
| Utilizator | Data | 31 ianuarie 2019 10:07:50 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.63 kb |
#include <iostream>
#include <fstream>
#include <climits>
#define mod 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long n,p,rez=1;
long long inm(long long x,long long y)
{
long long con=1,sol=1;
while(con<=y)
{
sol=(sol*x)%mod;
con++;
}
return sol;
}
int main()
{
in>>n>>p;
long long pt=inm(n,20000),cont=20000;
while(cont<=p)
{
rez=(rez*pt)%mod;
cont+=20000;
}
if(cont>p)cont=cont-20000+1;
while(cont<=p)
{
rez=(rez*n)%mod;
cont++;
}
out<<rez;
return 0;
}
