typedef long long LL;
LL mul(LL a, LL b, LL mod) {
LL ret = 0;
while (b) {
if (b & 1)
(ret+=a)%=mod;
b>>=1, (a<<=1)%=mod;
}
return ret;
}
LL mpow(LL x, LL y, LL mod) {
LL ret = 1;
while (y) {
if (y & 1)
ret = mul(ret, x, mod);
y >>= 1, x = mul(x, x, mod);
}
return ret;
}
直接乘的话,会爆long long ,所以采取一边加,一边模的温和运算。