mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-18 04:11:59 +00:00
18 lines
372 B (Stored with Git LFS)
C++
18 lines
372 B (Stored with Git LFS)
C++
#include <cstdio>
|
|
using namespace std;
|
|
int a, b, m;
|
|
|
|
int Ksm(int x, int d) {
|
|
int res = 1;
|
|
for (; d; d /= 2, x = 1ll * x * x % m)
|
|
if (d % 2) res = 1ll * res * x % m;
|
|
return res;
|
|
}
|
|
|
|
int main() {
|
|
freopen("data10.in", "r", stdin);
|
|
freopen("data10.out", "w", stdout);
|
|
scanf("%d%d%d", &a, &b, &m);
|
|
printf("%d", Ksm(a, b));
|
|
}
|