mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 23:16:27 +00:00
18 lines
271 B
C++
18 lines
271 B
C++
|
#include <bits/stdc++.h>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
long long a, b, p, ans = 1;
|
||
|
|
||
|
int main() {
|
||
|
cin >> a >> b >> p;
|
||
|
a %= p;
|
||
|
while (b) {
|
||
|
if (b & 1) ans = ans * a % p;
|
||
|
a = a * a % p;
|
||
|
b >>= 1;
|
||
|
}
|
||
|
cout << ans % p << endl;
|
||
|
return 0;
|
||
|
}
|