// 快速幂,求a^b mod pintpower(int a,int b,int p){int ans =1;for(; b; b >>=1){if(b &1) ans =(longlong)ans * a % p;
a =(longlong)a * a % p;}return ans;}// 64位整数乘法的O(log b)算法longlongmul(longlong a,longlong b,longlong p){longlong ans =0;for(; b; b >>=1){if(b &1) ans =(ans + a)% p;
a = a *2% p;}return ans;}// 64位整数乘法的long double算法longlongmul(longlong a,longlong b,longlong p){
a %= p, b %= p;// 当a,b一定在0~p之间时,此行不必要。longlong c =(longdouble)a * b / p;longlong ans = a * b - c * p;if(ans <0) ans += p;elseif(ans >= p) ans -= p;return ans;}