Cod sursa(job #2891016)
Utilizator | stroe cristian emanuel cristiemanuel | Data | 17 aprilie 2022 12:51:06 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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) {
if (!b)
return 1;
int P = lgput(a, b / 2);
P = ((long long) P * P) % mod;
if (b % 2 == 1)
P = ((long long) P * a) % mod;
return P;
}
int main()
{
int a, b;
in >> a >> b;
out<<lgput(a, b);
}