快速乘模板
logn级别
inline ll mult_mod(ll a, ll b, ll m) { ll res = 0; while(b){ if(b&1) res = (res+a)%m; a = (a+a)%m; b >>= 1; } return res; }
O(1)级别
inline ll mult_mod(ll a, ll b, ll m) { ll c = a*b-(ll)((long double)a*b/m+0.5)*m; return c<0 ? c+m : c; //就是算的a*b%m; }