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