Cod sursa(job #2636617)
Utilizator | Data | 18 iulie 2020 21:05:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <cmath>
#define mod 1999999973
using namespace std;
int n;
long long a, b, rez;
int putere() {
rez = 1;
while (b > 0) {
if (b % 2 != 0)
rez = rez * a % mod;
a = a * a % mod;
b /= 2;
}
return rez;
}
int main() {
cin >> a >> b;
cout << putere() << "\n";
return 0;
}