Cod sursa(job #2900007)
| Utilizator | Data | 9 mai 2022 21:21:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
# define ll unsigned long long
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 10000009;
ll Ceface(int x, int n) {
if (n == 0)
return 1;
if (n % 2 == 1)
return x * Ceface(x, n - 1);
// ll res = Ceface(x, n / 2);
return Ceface(x, n / 2) * Ceface(x, n / 2);
}
int main() {
int x, n;
in>>x>>n;
out<<Ceface(x, n);
}
