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