Pagini recente » Cod sursa (job #87847) | Monitorul de evaluare | Cod sursa (job #1543114) | Cod sursa (job #2330461) | Cod sursa (job #192831)
Cod sursa(job #192831)
#include <stdio.h>
#include <stdlib.h>
int lgpow (int base, int exp)
{
int a;
if (!exp) return 1;
//int ret=base;
//while (exp>1) { ret *= base; base *= base; exp /= 2; }
//return ret;
return (a=lgpow(base,exp/2))*a*(exp%2==0?1:base);
}
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);
}