Pagini recente » Cod sursa (job #1173302) | Cod sursa (job #3164648) | Cod sursa (job #896659) | Cod sursa (job #561216) | 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;
}