Cod sursa(job #2742523)
| Utilizator | Data | 21 aprilie 2021 09:44:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
int n, p;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long putere(int x, int y) {
if (y == 0) {
return 1;
}
if (y % 2 == 0) {
return putere(x, y / 2) * putere(x, y / 2) % 1999999973;
}
return x * putere(x, y - 1) % 1999999973;
}
int main() {
f >> n >> p;
g << putere(n, p) % 1999999973;
}
