Cod sursa(job #3302714)
| Utilizator | Data | 10 iulie 2025 12:27:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
int logpow(int a, int b) {
if (b == 0) return 1;
if (b % 2 == 0) {
int half = logpow(a, b / 2);
return (1LL * half * half) % MOD;
} else {
return (1LL * a * logpow(a, b - 1)) % MOD;
}
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int a, b;
fin >> a >> b;
fout << logpow(a, b) << endl;
return 0;
}