Cod sursa(job #914644)
Utilizator | Data | 14 martie 2013 12:31:28 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<stdio.h>
long long p,n,r;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%L64d %L64d",&n,&p);
r=1;
while(p!=0)
{
if(p%2==1)
{
r=(r*n)%1999999973;
}
n=(n*n)%1999999973;
p=p/2;
}
printf("%L64d",r);
fclose(stdout);
return 0;
}