Pagini recente » Cod sursa (job #670001) | Cod sursa (job #2654426) | Cod sursa (job #92182) | Cod sursa (job #452850) | Cod sursa (job #3135159)
#include <iostream>
#include <fstream>
using namespace std;
const int nr = 1999999973;
long long lgcalc(int x, int n)
{
if (n == 0)
return 1;
if (n % 2)
return lgcalc(x * x % nr, n / 2) % nr;
else
return (x * lgcalc(x * x % nr, (n - 1) / 2)) % nr;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int N, P;
fin >> N >> P;
long long rz = lgcalc(N, P);
fout << rz;
return 0;
}