//将b转化成二进制数,a * b = a * (100100...1) = a * 2^(k-1) + a * 2^(k-4) + ... + a * 2^0
//= a * 2^0 + ... + 2^(k-4) + 2^(k-1),类比快速幂,对a进行预处理
int mul(int a, int b, int p)
{
int res = 0;
while(b)
{
if(b & 1) res = (res + a) % p;
b >>= 1;
a = a * 2 % p;
}
return res;
}