Cod sursa(job #3141482)
| Utilizator | Data | 14 iulie 2023 10:47:58 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int DIVISOR = 1999999973;
long long power(int a, int b) {
if (b == 0) {
return 1;
}
//long long num = power(a, b / 2);
if (b % 2 == 0) {
return power(a, b / 2) * power(a, b / 2) % DIVISOR;
}
return (a % DIVISOR) * power(a, b-1) % DIVISOR;
}
int main() {
int n, p;
fin >> n >> p;
fout << power(n, p);
return 0;
}
