Pagini recente » Cod sursa (job #961969) | Cod sursa (job #2455834) | Cod sursa (job #1025821) | Cod sursa (job #1672202) | Cod sursa (job #192872)
Cod sursa(job #192872)
#include <stdio.h>
#include <stdlib.h>
int lgpow (int base, int exp)
{
int ret = 1;
while (exp) {
if (exp & 1) {
--exp;
ret *= base;
}
base *= base;
exp /= 2;
}
return ret;
}
int main (void)
{
FILE *in, *out;
int base, exp;
in = fopen("lgput.in", "r");
out = fopen("lgput.out", "w+");
if (!in || !out) { printf("WTF?"); exit(-1); }
fscanf(in, "%d %d", &base, &exp);
fprintf(out, "%d\n", lgpow(base, exp)%1999999973);
fclose(in); fclose(out);
}