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