Cod sursa(job #265933)
| Utilizator | Data | 24 februarie 2009 19:13:18 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
int main()
{
unsigned long baza,putere,rez=1;
ifstream f("lgput.in");
f>>baza>>putere;
f.close();
unsigned long adun=baza;
while (putere>0)
{ if (putere%2!=0) rez=rez*adun;
adun=adun*adun;
putere=putere/2;
}
ofstream g("lgput.out");
g<<rez;
g.close();
return 0;
}
