Cod sursa(job #505252)
Utilizator | Data | 1 decembrie 2010 11:14:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <stdio.h>
const int n_max = 10001;
const int m = 1999999973;
int main()
{
unsigned int i, n, p;
long long a, j = 1, k;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d", &n, &p);
a = n;
k=n%m;
while(p)
{
if(p%2==0)
j=(j*k)%m;
k=(k*k)%m;
p/2;
}
printf("%lld\n", j);
}