Pagini recente » Cod sursa (job #677051) | Cod sursa (job #1438355) | Cod sursa (job #506521) | Cod sursa (job #1356931) | Cod sursa (job #1730670)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long exp_by_squaring(long long x,int n)
{
if(n<0)
return exp_by_squaring(1/x,-n);
else
{
if(n==0)
return 1;
else
{
if(n==1)
return x%1999999973;
else
{
if(n%2==0)
return (exp_by_squaring((x*x)%1999999973,n/2))%1999999973;
else
return (x*exp_by_squaring((x*x)%1999999973,(n-1)/2))%1999999973;
}
}
}
}
int main()
{
int a,b;
f>>a>>b;
g<<exp_by_squaring(a,b)%1999999973;
f.close();
g.close();
return 0;
}