Pagini recente » Cod sursa (job #1889842) | Cod sursa (job #2421393) | Cod sursa (job #40574) | Cod sursa (job #1158609) | 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;
}