#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll QuickPow(ll a, ll b, ll mod) {
ll ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans % mod;
}
int main() {
ll a, b, p;
scanf("%lld %lld %lld", &a, &b, &p);
printf("%lld\n", QuickPow(a, b, p));
return 0;
}
快速幂模板
最新推荐文章于 2024-07-25 06:55:26 发布