0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#10194. 「一本通 6.1 练习 1」A 的 B 次方

https://loj.ac/s/1025643
This commit is contained in:
Baoshuo Ren 2021-01-03 10:23:06 +08:00 committed by Baoshuo Ren
parent c830ea65ac
commit 85c12c8df7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

21
LibreOJ/10194/10194.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
int main() {
long long a, b, m;
cin >> a >> b >> m;
cout << binpow(a, b, m) << endl;
return 0;
}