Pagini recente » Cod sursa (job #988241) | Cod sursa (job #417578) | Cod sursa (job #1973593) | Cod sursa (job #513292) | Cod sursa (job #661734)
Cod sursa(job #661734)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
int N, P, CONST = 1999999973;
int exponentiation(int x, int p)
{
if (p == 0)
return 1;
else
if (p % 2)
return x * (int)pow(exponentiation(x, (p - 1) / 2), 2);
else
return (int)pow(exponentiation(x, p / 2), 2);
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d", &N, &P);
printf("%d", exponentiation(N, P) % CONST);
}