Pagini recente » Cod sursa (job #336250) | Cod sursa (job #2564141) | Cod sursa (job #11015) | Cod sursa (job #1678495) | Cod sursa (job #1098649)
/* Ridicare la putere folosind exponentiere logaritmica */
#include <fstream>
using namespace std;
#define MOD 1999999973
long long N, P, R;
void Pow(long long P)
{
if (P == 0)
{
R = 1;
return;
}
else
{
Pow(P / 2);
if (P % 2)
{
R = ((R * R) % MOD * N) % MOD;
}
else
{
R = (R * R) % MOD;
}
}
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f >> N >> P;
Pow(P);
g << R;
}