Pagini recente » Cod sursa (job #986779) | Profil yopetrucci | Cod sursa (job #2000199) | Cod sursa (job #1773446) | Cod sursa (job #3295963)
#include <fstream>
#include <iostream>
using namespace std;
int exponentiation_by_sq(int n, int p) {
if (n == 0)
return 1;
if (p % 2 == 0)
return exponentiation_by_sq(n * n, p / 2);
if (p % 2 == 1) {
return n * exponentiation_by_sq(n * n, (p - 1) / 2);
}
// cout << "Error" << endl;
// exit(-1);
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned int n, p;
fin >> n >> p;
fout << exponentiation_by_sq(n, p) % 1999999973;
return 0;
}