Cod sursa(job #1569460)
Utilizator | Data | 15 ianuarie 2016 16:36:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<fstream>
using namespace std;
long long pow0(long x,long y)
{
long a=1;
while(y)
{
if(y%2==1)
a=a*x;
a=a*a;
y/=2;
}
return a;
}
int main()
{
long x,y;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>x>>y;
if(pow0(x,y)>1999999973)
fout<<pow0(x,y)%1999999973;
else
fout<<pow0(x,y);
return 0;
}