Cod sursa(job #2891009)
Utilizator | Data | 17 aprilie 2022 12:47:11 | |
---|---|---|---|
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>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 1999999973;
#define ll long long
int lgput(int a, int b) {
int P;
if (!b)
return 1;
else {
P = lgput(a, b / 2);
P = (1LL * P * P) % mod;
if (P % 2 == 1)
P = (1LL * P * a) % mod;
}
return P;
}
int main()
{
int a, b;
in >> a >> b;
out<<lgput(a, b);
}