0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 08:48:49 +00:00
OI-codes/LibreOJ/10194/data/1.cpp

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));
}