Cod sursa(job #250227)
Utilizator | Data | 30 ianuarie 2009 13:33:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <stdio.h>
#define k 1999999973
long n, i, t=1, p;
int main(void)
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf ("%ld%ld", &n, &p);
while(p)
{
if(p%2)
t=(t*n)%k;
n=n*n%k;
p/=2;
}
printf("%ld", t);
fcloseall();
return 0;
}