Cod sursa(job #2959683)
| Utilizator | Data | 2 ianuarie 2023 12:12:45 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int log_exp(long long a, long long b) {
if (b == 1) {
return a % 1999999973;
}
if (b % 2 == 0) {
long long ok = log_exp(a, b / 2);
return ok * ok % 1999999973;
}
return a * log_exp(a, b - 1) % 1999999973;
}
int main() {
long long a, b;
fin >> a >> b;
fout << log_exp(a, b);
}
