Cod sursa(job #238857)
Utilizator | Data | 3 ianuarie 2009 14:38:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <stdio.h>
#define NR 1999999973
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long n,p,s=1;
scanf("%lld%lld",&n,&p);
n=n%NR;
while(p)
{
if (p%2)
s=s*n%NR;
n=n*n%NR;
p/=2;
}
printf("%lld\n",s);
return 0;
}