Pagini recente » Cod sursa (job #1105829) | Cod sursa (job #1928660) | Cod sursa (job #869230) | Monitorul de evaluare | Cod sursa (job #192875)
Cod sursa(job #192875)
#include <stdio.h>
#include <stdlib.h>
#define MOD 1999999973
int lgpow (int base, int exp)
{
int ret = 1;
while (exp) {
if (exp & 1) {
--exp;
ret = (ret*base)%MOD;
}
base *= base;
exp /= 2;
}
return ret%MOD;
}
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));
fclose(in); fclose(out);
}