mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:28:48 +00:00
22 lines
377 B
C++
22 lines
377 B
C++
#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;
|
|
}
|