Cod sursa(job #2572085)
| Utilizator | Data | 5 martie 2020 11:34:29 | |
|---|---|---|---|
| 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;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
const int MOD = 1999999973;
ll a, b;
ll lgpow(ll base, ll exp) {
ll ans;
ans = 1;
while (exp > 0) {
if (exp % 2 > 0) {
ans = (1LL * ans * base) % MOD;
}
exp /= 2;
base = (1LL * base * base) % MOD;
}
return ans;
}
int main() {
fin >> a >> b;
fout << lgpow(a, b) << "\n";
return 0;
}
