Files
python/TangDou/AcWing/Math/P1226.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

21 lines
386 B
C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a, b, p;
LL qmi(LL x, LL y, LL p) {
LL res = 1;
while (y) {
if (y & 1) res = res * x % p;
y >>= 1;
x = x * x % p;
}
return res;
}
int main() {
scanf("%d %d %d", &a, &b, &p);
printf("%d^%d mod %d=%lld\n", a, b, p, qmi(a, b, p));
return 0;
}