标签:splay 组合 code rac pre 组合数 span inline return
\(A^m_n=n(n-1)(n-2) \cdot\ \cdot\ \cdot(n-m+1) =\frac{n!}{(n-m)!}\)
\(C^m_n=C^m_{n-1}+C^{m-1}_{n-1}\)
\(C^m_n=C^{n-m}_{n}\)
\(C^m_n=\frac{n}{m}×C^{m-1}_{n-1}\)
\(C^m_k×C^k_n=C^m_n×C^{n-k}_{n-m}(n-k<n-m)\)
\(\displaystyle\sum_{i=1}^n C^i_n = 2^n\)
\(\displaystyle\sum_{i=0}^n (-1)^i×C^i_n=0\)
\((a+b)^n = \displaystyle\sum_{i=0}^n C^i_na^{n-i}b^i\)(二项式定理)
\(C^m_n=\frac{A^m_n}{m!}=\frac{n!}{m!(n-m)!}=fac_n×invf_m×invf_{n-m}\)
阶乘预处理,逆元用费马小定理计算
\(C^m_n=C^{m\ mod\ p}_{n\ mod\ p}×C^{m/p}_{n/p}\)
其中\(p\)为质数
\(code :\)
ll C(ll n,ll m)
{
return n<m?0:((f[n]*qp(f[m],mod-2)%mod)*qp(f[n-m],mod-2))%mod;
}
ll lucas(ll n,ll m)
{
return m?(C(n%mod,m%mod)*lucas(n/mod,m/mod))%mod:1;
}
\(D_n=(n-1)(D_{n-1}+D_{n-2})\)
标签:splay 组合 code rac pre 组合数 span inline return
原文地址:https://www.cnblogs.com/lhm-/p/12229538.html