Cod sursa(job #2737500)
| Utilizator | Data | 4 aprilie 2021 20:06:53 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << "\n";
const int mod = 1999999973;
ifstream in("lgput.in");
ofstream out("lgput.out");
int a, b;
int lgpow(int a, int b) {
int ans = 1;
while (b > 0) {
if (b % 2 > 0) {
ans = (1LL * ans * a) % mod;
}
a = (1LL * a * a) % mod;
b /= 2;
}
return ans;
}
int main() {
in >> a >> b;
out << lgpow(a, b) << "\n";
return 0;
}
