Cod sursa(job #1680745)
Utilizator | Dragos Ristache MKLOL | Data | 9 aprilie 2016 01:03:00 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include<stdio.h>
#define MOD 1999999973LL
long long N,M,o;
long long powx(long long x,long long y)
{
if(y==1)
return x;
else if(y%2==0)
{
long long w=powx(x,y/2);
return (w*w)%MOD;
}
else
{
long long w=powx(x,y-1)%MOD;
return (w*x)%MOD;
}
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld",&N,&M);
N=N%MOD;
printf("%lld",powx(N,M));
}