Mai intai trebuie sa te autentifici.
Cod sursa(job #2217651)
Utilizator | Data | 1 iulie 2018 12:42:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
#define bigNum 1999999973
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long power(long long base, long long expo) {
long long res = 1;
while (expo) {
if (expo & 1) {
res = (res * base) % bigNum;
}
expo >>= 1;
base *= base;
}
return res % bigNum;
}
int main() {
long long base, expo;
fin >> base >> expo;
fout << power(base, expo);
}