Cod sursa(job #314491)
Utilizator | Data | 11 mai 2009 22:25:36 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
#define C 1999999973
long long a,b,p,sol;
int main() {
FILE *f = fopen("lgput.in","r");
FILE *g = fopen("lgput.out","w");
fscanf(f,"%lld %lld",&a,&b);
sol = 1;
p = a;
while (b) {
if (b & 1)
sol = (sol*p)%C;
p = (p*p)%C;
b >>= 1;
}
fprintf(g,"%lld\n",sol);
fclose(f);
fclose(g);
return 0;
}