Pagini recente » Cod sursa (job #1216987) | Cod sursa (job #1513065) | Cod sursa (job #1431054) | Cod sursa (job #264020) | Cod sursa (job #3230456)
#include <stdio.h>
#include <stdlib.h>
int exponent(int N, int P)
{
if(P == 0){
return 1;
}
else if(P % 2 == 0){
return exponent(N * N, P / 2);
}
else if(P % 2 != 0){
return N * exponent(N * N, (P - 1) / 2);
}
return 1;
}
int main(void)
{
FILE *input = fopen("lgput.in", "r");
FILE *output = fopen("lgput.out", "w");
int N, P;
fscanf(input, "%d", &N);
fscanf(input, "%d", &P);
fprintf(output, "%d", exponent(N, P) % 1999999973);
fclose(input);
fclose(output);
return 0;
}