Cod sursa(job #1019900)
Utilizator | Data | 1 noiembrie 2013 09:41:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
/*
~Keep it Simple!~
*/
#include <stdio.h>
long long n,p;
long long SimplePow(int n,int p)
{
long long put=1;
while(p)
{
if(p%2)
{
put *= n;
put %= 1999999973;
p--;
}
n*=n;
n %= 1999999973;
p/=2;
}
return put;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
printf("%lld",SimplePow(n,p));
}