mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 12:18:50 +00:00
89. a^b
https://www.acwing.com/problem/content/submission/code_detail/8019425/
This commit is contained in:
parent
fdb7b7a070
commit
ae929e4eb6
17
AcWing/89/89.cpp
Normal file
17
AcWing/89/89.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user