Pagini recente » Cod sursa (job #1048312) | Cod sursa (job #2701122) | Cod sursa (job #653817) | Cod sursa (job #2848254) | Cod sursa (job #2761855)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
int x, p, c=1;
in>>x>>p;
while(p>0)
{
if(p%2==1)
c=x*c%1999999973;
x*=x;
x%=1999999973;
p/=2;
}
out<<c;
return 0;
}
/*
int main()
{
long long x, p, c=1;
in>>x>>p;
if(p==1)
c=1;
else if(p==0)
x=1;
else
while(p>1)
{
if(p%2==0)
{
x*=x;
p/=2;
}
else
{
x=x*c;
x*=x;
p=(p-1)/2;
}
}
out<<x*c;
return 0;
}
*/