Cod sursa(job #387607)
Utilizator | Data | 27 ianuarie 2010 23:19:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 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)%mod;
p=p>>1;
}
printf("%lld\n",prod%mod);
return 0;
}