Cod sursa(job #387603)
Utilizator | Data | 27 ianuarie 2010 23:12:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<stdio.h>
#define mod 1999999973
long long prod=1,n,p,pow;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
pow=n;
while(p)
{
if (1&p)
prod=(prod*pow)%mod;
pow=pow*pow;
p=p>>1;
}
printf("%lld",prod);
return 0;
}