快速乘
LL mod_multi(LL x,LL y,LL mod)
//拆分成y个x相加
{
LL res = 0;
while
(y)
{
if
(y&1)
{
res += x;
while
(res >= mod) res -= mod;
}
x += x;
while
(x >= mod) x -= mod;
y >>= 1;
}
return
res;
}
LL mod_pow(LL x,LL n,LL mod)
{
LL res = 1;
while
(n > 0)
{
if
(n&1)
{
res = mod_mulit(res,x,mod);
// res = res*x%mod;
}
x = mod_multi(x,x,mod);
//x = x*x%mod;
n >>= 1;
}
return
res;
}