Cod sursa(job #2953801)
| Utilizator | Data | 12 decembrie 2022 10:39:50 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int exp(long long x, long long n) {
if (n == 1) {
return x;
}
if (n % 2 == 1) {
return x * exp(x, n - 1);
}
int tmp_exp = exp(x, n / 2);
return tmp_exp * tmp_exp;
}
int main() {
long long x, n;
fin >> x >> n;
fout << exp(x, n) % 1999999973;
}
