快速幂:求 a^b % p

1 #include <iostream>
2 using namespace std;
3
4 typedef long long LL;
5
6 LL qmi(LL a, LL b, LL p){
7 LL res = 1 % p;
8 while(b){
9 if(b & 1)res = res * a % p;
10 a = a * a % p;
11 b >>= 1;
12 }
13 return res;
14 }
来源:https://www.cnblogs.com/sxq-study/p/12255144.html
