组合计数
Posted smeow
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了组合计数相关的知识,希望对你有一定的参考价值。
minmax容斥:
锅:kth
用于求解期望最大值(最大值的期望),((maxRightarrow min))。
[E(max(S))=sum_{Tsubseteq S}(-1)^{|T|+1} imes E(min(T))]
[=sum_{Tsubseteq S}(-1)^{|T|+1} imes frac{1}{1-P(min(?_u T))}]
[E(min(S))=frac{1}{P(min(S))}]
[P(min(S))=sum_{x igcap S
eq emptyset }P(x)]
[~~~~~~~~~~~~~~~~~~~~~~~~~=1-sum_{x igcap S= emptyset }P(x)]
[~~~~~~~~~~~~~~~~~~~~~~~~~=1-sum_{x subseteq ?_uS}P(x)]
[=1-P(min(?_u S))=sum_{x subseteq S}P(x)]
HAOI
HDU4624(minmax&&容斥套路2)
期望的线性性:
[E(X+Y)=E(X)+E(Y)]
组合数公式:
[{{-r}choose {y}}=(-1)^y imes {r+y-1choose y}]
[{nchoose m}=frac{n imes(n-1) imes(n-2) imesdots imes(n-m+1)}{m!}(nin Z)]
[{n+mchoose k}=sum_{i=0}^{k}{nchoose i} imes{mchoose k-i}]
[sum_{k=0}^{n}{nchoose k}^2={2nchoose n}]
[sum_{r=0}^{n}{nchoose r}=2^n]
[sum_{r=0}^{k}{n+r-1choose r}={n+kchoose k}]
[sum_{i=1}^n i imes {nchoose i} imes x^i=n imes (1+x)^{n-1}]
[{nchoose m}\\%2==1 <=>(n&m)==m]
[{nchoose m}=prod_{i=1}^k frac{n+1-i}{i}]
[sum_{i=1}^n{ichoose m}={n+1choose m+1}]
[sum_{i=1}^m{nchoose i}=F(n,m)]
[{egin{cases}{F(i,i)=1}\\{F(i,j+1)=F(i,j)+{ichoose j+1}}\\{F(i+1,j)=2 imes F(i,j)-{ichoose j}}end{cases}}]
[F(i,j)=F(i\\%p,p-1) imes F(frac{n}{p},frac{k}{p}-1)+{frac{k}{p}choose frac{n}{p}} imes F(n\\%p,k\\%p)]
[-ij={ichoose 2}+{jchoose 2}-{i+jchoose 2}]
套路:
(1.)利用(dp)(背包)合并容斥系数((1,-1))。(有上界的划分数类问题)
(2.)套路1+神奇思路ZOJ4064
(3.)
(4.)CF932 G
(5.)CF348 D
(LGV~lemma)定理:n个起点,n个终点,一一对应,求互不相交的路径有多少种:
[ ans=determinant left[ egin{matrix} e(x_1,y_1) & e(x_1,y_2) & cdots & e(x_1,y_n) \\ e(x_2,y_1) & e(x_2,y_2) & cdots & e(x_2,y_n) \\ vdots &vdots &ddots &vdots \\ e(x_n,y_1) & e(x_n,y_2) & cdots & e(x_n,y_n)end{matrix}
ight] ]
(~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~e(x,y)=x)到(y)的合法路径条数
(6.)类(LGV~lemma):n维空间,从((x_1,x_2dots x_n))走到((y_1,y_2dots y_n))方案数[=(sum y_i-sum x_i)! imes e]
[ e=determinant left[ egin{matrix} frac{1}{(y_1-x_1)!} & frac{1}{(y_1-x_2)!} & cdots & frac{1}{(y_1-x_n)!} \\ frac{1}{(y_2-x_1)!} & frac{1}{(y_2-x_2)!} & cdots & frac{1}{(y_2-x_n)!} \\ vdots &vdots &ddots &vdots \\ frac{1}{(y_n-x_1)!} & frac{1}{(y_n-x_2)!} & cdots & frac{1}{(y_n-x_n)!} end{matrix}
ight] ]
(7.)半容斥:无向连通图个数=总数-不联通的图的个数(基准点计数)传送门,一类套路CF53E Dead Ends。
(8.)对于递推方程:[f(i)=a imes f(i-p)+b imes f(i-q)]
可以理解成每次选择花费(a)的代价走(p)步,或者花费(b)的代价走(q)步那么[f(n)=sum_{i=0}^{lfloor frac{n}{p}
floor} {i+frac{(n-i imes p)}{q}choose i} imes a^i imes b^{frac{(n-i imes p)}{q}}~~~~~~~~~~~(q|(n-i imes p))]PE 427(q=1),枚举(p),复杂度(O(n^2) Rightarrow O(nlogn))
由此可推
[sum_{i=0}^{lfloor frac n k
floor} {n-ichoose i}<=>f(n)=f(n-1)+f(n-k)]
(10.)考虑组合意义:
[x^k=sum_{i=0}^{x~or~k}{xchoose i} imes i! imes S(k,i)]
以上是关于组合计数的主要内容,如果未能解决你的问题,请参考以下文章