Cod sursa(job #2891033)
Utilizator | Data | 17 aprilie 2022 13:10:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 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 r = 1;
while(b){
if ( b % 2 == 1)
r = (1LL *r * a) % mod;
a = (1LL a * a) % mod;
b /= 2;
}
return r;
}
int main()
{
int a, b;
in >> a >> b;
out<<lgput(a, b);
}