Cod sursa(job #494861)
Utilizator | Data | 23 octombrie 2010 10:37:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | tema_1_10f | Marime | 0.29 kb |
#include <cstdio>
const int N=1999999973;
long long a,l,n,p;
int main ()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&p,&n);
l=1;
while (n!=0)
{
if (n%2==1)
{
l=l*p%N;
}
p=p*p%N;
n=n/2;
}
printf("%lld",l);
return 0;
}