Cod sursa(job #1133912)
Utilizator | Data | 5 martie 2014 19:57:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long x,y,p;
inline void Citire()
{
fin>>x>>y;
}
inline void Rezolva()
{
p=1;
while (y!=0)
{
if (y%2==1)
{
y--;
p=p*x;
}
x=x*x;
y>>=1;
}
fout<<p<<"\n";
}
int main()
{
Citire();
Rezolva();
//fout<<n<<" "<<p;
return 0;
}