Pagini recente » Cod sursa (job #2931800) | Monitorul de evaluare | Cod sursa (job #1911163) | Cod sursa (job #1975275) | Cod sursa (job #1522031)
#include <fstream>
#define mod 1999999973
using namespace std;
long long expRap(long long a, long long b)
{
if (b == 0) return 1;
int aux = 1;
while (b > 1)
{
if (b % 2 == 0)
{
a = (a * a) % mod;
b /= 2;
}
else
{
aux = (aux * a) % mod;
b--;
}
}
return (a * aux) % mod;
};
long long n, p;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f >> n >> p;
long long rez = expRap(n, p);
if (rez > 0) g << rez;
else g << rez + mod;
return 0;
}