Cod sursa(job #265940)
| Utilizator | Data | 24 februarie 2009 19:16:33 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 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)%1999999973;
adun=(adun*adun)%1999999973;
putere=putere/2;
}
ofstream g("lgput.out");
g<<rez;
g.close();
return 0;
}
