Pagini recente » Cod sursa (job #182670) | Cod sursa (job #587082) | Cod sursa (job #1195849) | Cod sursa (job #1180409) | 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;
}