Cod sursa(job #1569456)
Utilizator | Data | 15 ianuarie 2016 16:32:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<fstream>
using namespace std;
int pow0(int x,int y)
{
int 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;
}