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

H1032. 【模板】快速幂

https://hydro.ac/record/61580a1c2a2aefdda01dcf8a
This commit is contained in:
Baoshuo Ren 2021-10-02 15:28:30 +08:00 committed by Baoshuo Ren
parent 4c70b1085c
commit 803bd3a891
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

21
Hydro/H1032/H1032.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 p) {
long long res = 1;
a %= p;
while (b) {
if (b & 1) res = res * a % p;
a = a * a % p;
b >>= 1;
}
return res;
}
int main() {
long long a, b, p;
cin >> a >> b >> p;
cout << binpow(a, b, p) << endl;
return 0;
}