Pagini recente » Cod sursa (job #304599) | Cod sursa (job #3249164) | Cod sursa (job #598276) | Cod sursa (job #1325160) | Cod sursa (job #3135157)
#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 != 0)
return (x * lgcalc(x * x % nr, (n - 1) / 2)) % nr;
else
return lgcalc(x * x % nr, n / 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;
}