Cod sursa(job #558186)
Utilizator | Data | 17 martie 2011 09:41:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <fstream>
using namespace std;
long long n,p,px,r,rez;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
px=n;
rez=1;
while (n)
{
r=n%2;
if (r)
rez*=px;
px*=px;
n/=2;
}
g<<rez<<'\n';
f.close();
g.close();
return 0;
}