Cod sursa(job #405034)
Utilizator | Data | 27 februarie 2010 12:33:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include<stdio.h>
long long int res,n,p;
int main()
{freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
res=1;
while(p)
{if(p%2) res=(res*n)%1999999973;
n=(n*n)%1999999973;
p/=2;
}
printf("%lld",res);
}