Cod sursa(job #2217654)
| Utilizator | Data | 1 iulie 2018 12:46:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 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 > 0) {
if (expo & 1) {
res = (res * base) % bigNum;
}
expo = expo >> 1;
base = (base * base) % bigNum;
}
return res % bigNum;
}
int main() {
long long base, expo;
fin >> base >> expo;
fout << power(base, expo);
}