写法最易懂的快速幂
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
long long a, b, p; cin >> a >> b >> p;
long long res = 1;
if(b==0) res = 1%p;
while(b)
{
if(b%2==1) res=res*a%p, b-=1;
else a=a*a%p, b/=2;
}
cout << res << endl;
return 0;
}
好难啊