Pagini recente » Cod sursa (job #167974) | Profil tudgal1001 | Diferente pentru utilizator/tvlad intre reviziile 21 si 22 | Cod sursa (job #1749345) | Cod sursa (job #1773579)
#include <fstream>
#include <iostream>
using namespace std;
int modularPow(unsigned long long base, unsigned long long exp, int mod)
{
int result = 1;
while (exp)
{
if (exp & 1)
result = ((result % mod) * (base % mod)) % mod;
base = ((base % mod) * (base % mod)) % mod;
exp >>= 1;
}
return result;
}
int main()
{
unsigned long long N, P;
ifstream f("lgput.in");
f >> N >> P;
f.close();
ofstream g("lgput.out");
g << modularPow(N, P, 1999999973);
g.close();
return 0;
}