Cod sursa(job #2890998)
Utilizator | stroe cristian emanuel cristiemanuel | Data | 17 aprilie 2022 12:37:01 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 1999999973;
#define ll long long
ll lgput(ll a, ll b) {
ll P;
if (!b)
return 1;
else {
P = (lgput(a, b / 2)) % mod;
P = (P * P) % mod;
if (P % 2 == 1)
P = (P * a) % mod;
}
return P;
}
int main()
{
ll a, b;
in >> a >> b;
out<<lgput(a, b);
}