Pagini recente » Cod sursa (job #1021989) | Cod sursa (job #1020712) | Cod sursa (job #749051) | Cod sursa (job #2131887) | Cod sursa (job #2739372)
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
int lgput(long long e, int b)
{
if (e == 1) {
return b;
} else if (e % 2 == 1) {
return (1LL * b * lgput(e - 1, b)) % MOD;
} else {
int rez = lgput(e / 2, b);
return (1LL * rez * rez) % MOD;
}
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n, p;
fin >> n >> p;
fout << lgput(n, p);
fin.close();
fout.close();
return 0;
}