求 a^b (modp) 时间复杂度O(logn) 符合结合律 (一个整数n,二进制位数为 logn+1)
int quickpow(ll a,int b,int p){ int res=1; while(b){ if(b&1) res=res*a%p; a=a*a%p; b>>=1; } return res; }