C++ 代码
#include<iostream>
using namespace std;
int main()
{
int a,b,p;
cin >> a >> b >> p;
int res = 1 % p; //如果p为1的话,那么无论什么数的结果都是0
while(b)
{
if(b & 1) res = (long long)res * a % p;
a = (long long)a * a % p;
b >>= 1;
}
cout << res << endl;
return 0;
}