Cod sursa(job #2224802)
Utilizator | Data | 25 iulie 2018 10:19:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int b, e;
fin >> b >> e;
int rez = 1, mod = 1999999973;
while(e){
if(e % 2 == 1){
rez *= b;
b *= b % mod;
e /= 2;
}
else{
b *= b % mod;
e /= 2;
}
}
fout << rez;
return 0;
}