Pagini recente » Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #2019544) | Cod sursa (job #2843569) | Cod sursa (job #2952392)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int p1(long long x, long long x_cpy, int n, int i) {
if (i == n / 2) {
return x * x;
}
p1(x * x_cpy, x_cpy, n, i + 1);
}
int p2(long long x, long long x_cpy, int n, int i) {
if (i == n - 1) {
return x_cpy * x;
}
//cout << "x = " << x << "\n";
p2(x * x_cpy, x_cpy, n, i + 1);
}
int main() {
long long x;
int k = 1999999973, n;
fin >> x >> n;
if (n == 0) {
fout << 1 % k;
} else if (n % 2 == 0) {
long long x_cpy = x;
fout << p1(x, x_cpy, n, 1) % k;
} else {
long long x_cpy = x;
fout << p2(x, x_cpy, n, 1) % k;
}
return 0;
}