Cod sursa(job #2238803)
Utilizator | Data | 7 septembrie 2018 17:44:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long b, e;
fin >> b >> e;
long long rez = 1LL, mod = 1999999973;
while(e){
if(e % 2 == 1){
rez *= b;
rez %= mod;
}
b *= b;
b %= mod;
e /= 2;
}
fout << rez;
return 0;
}