快速幂

#include <iostream>
using namespace std;
typedef long long ll;
ll pow(ll a, ll b, ll p){
	ll ans = 1, base = a;
	while (b){
		if (b & 1)	ans = ans * base % p;
		base = base * base % p;
		b >>= 1;
	}
	return ans;
} 
int main(){
	ll a, b, p;
	cin >> a >> b >> p;
	cout << pow(a, b, p);
	return 0;
}