https://www.acwing.com/problem/content/91/
考察快速幂的知识;
1 #include<iostream> 2 using namespace std; 3 typedef long long LL; 4 LL ksm(LL a,LL b,LL p){ 5 LL res=1; 6 while(b){ 7 if(b&1){ 8 res=(res*a)%p; 9 } 10 a=a*a%p; 11 b>>=1; 12 } 13 return res%p; 14 } 15 int main(void){ 16 LL a,b,p; 17 cin>>a>>b>>p; 18 cout<<ksm(a,b,p); 19 return 0; 20 }