Pagini recente » Cod sursa (job #668657) | Cod sursa (job #2705616) | Cod sursa (job #181416) | Cod sursa (job #309343) | Cod sursa (job #584186)
Cod sursa(job #584186)
#include <fstream>
using namespace std;
unsigned long long int p, x, x1, x2;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin >> x >> p;
x1 = 1;
x2 = 1;
if(p > 1)
{
while(p != 1)
{
if(p % 2 == 1)
{
x1 = x1 * x % 1999999973;
p--;
}
else
{
if(x2 != 1)
x2 = x2 * x2 % 1999999973;
else
x2 = x * x % 1999999973;
p = p/2;
}
}
fout << x1 * x2 % 1999999973;
}
else
{
if(p == 0)
fout << 1;
else
fout << x;
}
fout.close();
fin.close();
return 0;
}