广义容斥-二项式反演-容斥系数

(好久没碰差点忘了,赶快泄个推导

目的是求恰好满足 k k k个要求的方案数 P ( k ) P(k) P(k)

考虑还是用满足至少 i i i个条件的式子算,不过要为原来的式子构造容斥系数 α ( j ) \alpha(j) α(j)
∑ i = 0 n ( n i ) α ( i ) Q ( i ) \sum_{i=0}^{n}\binom{n}{i}\alpha(i)Q(i) i=0n(in)α(i)Q(i)
可以考虑 P ( i ) ​ P(i)​ P(i)被算了几次。
∑ i = 0 n ( n i ) α ( i ) Q ( i ) = ∑ i = 0 n P ( i ) ∑ j = 0 n ( i j ) α ( j ) \sum_{i=0}^{n}\binom{n}{i}\alpha(i)Q(i)=\sum_{i=0}^n{P(i)\sum_{j=0}^n\binom{i}{j}\alpha(j)} i=0n(in)α(i)Q(i)=i=0nP(i)j=0n(ji)α(j)
目的是强制使得 P ( k ) = ∑ i = 0 n P ( i ) ∑ j = 0 n ( i j ) α ( j ) P(k)=\sum_{i=0}^n{P(i)\sum_{j=0}^n\binom{i}{j}\alpha(j)} P(k)=i=0nP(i)j=0n(ji)α(j)成立。

所以容斥系数的效果实际上就是
∑ j = 0 n ( i j ) α ( j ) = [ i = = k ] \sum_{j=0}^n\binom{i}{j}\alpha(j)=[i==k] j=0n(ji)α(j)=[i==k]
发现 j > i j>i j>i时其实没用,变成 ∑ j = 0 i ( i j ) α ( j ) = [ i = = k ] \sum_{j=0}^i\binom{i}{j}\alpha(j)=[i==k] j=0i(ji)α(j)=[i==k]

α ( i ) \alpha(i) α(i)单独丢出来,发现可以 n 2 n^2 n2搞出每个容斥系数,即
α ( i ) = [ i = = k ] − ∑ j = 0 i − 1 ( i j ) α ( j ) \alpha(i)=[i==k]-\sum_{j=0}^{i-1}\binom{i}{j}\alpha(j) α(i)=[i==k]j=0i1(ji)α(j)
恰好满足 k k k个要求的方案数对应的 α ( i ) \alpha(i) α(i)对应的可以取 α ( j ) = ( j k ) ( − 1 ) j − k \alpha(j)=\binom{j}{k}(-1)^{j-k} α(j)=(kj)(1)jk

i < k i<k i<k时式子始终为 0 0 0,当 i ≥ k i\geq k ik时有
∑ j = 0 i ( i j ) α ( j ) = ∑ j = 0 i ( i j ) ( j k ) ( − 1 ) j − k = ∑ j = k i ( i j ) ( j k ) ( − 1 ) j − k = ∑ j = 0 i − k ( i j + k ) ( j + k k ) ( − 1 ) j = ∑ j = 0 i − k i j + k ‾ ( j + k ) k ‾ ( j + k ) ! k ! ( − 1 ) j = ∑ j = 0 i − k i k ‾ ( i − k ) j ‾ ( j + k ) k ‾ k ! ( j + k ) k ‾ j ! ( − 1 ) j = ( i k ) ∑ j = 0 i − k ( i − k ) j ‾ j ! ( − 1 ) j = ( i k ) ∑ j = 0 i − k ( i − k j ) ( − 1 ) j = [ i − k = = 0 ] = [ i = = k ] \begin{aligned} & \sum_{j=0}^i\binom{i}j{}\alpha(j)\\ = & \sum_{j=0}^i{\binom{i}{j}\binom{j}{k}(-1)^{j-k}}\\ = & \sum_{j=k}^{i}\binom{i}{j}\binom{j}{k}(-1)^{j-k}\\ = & \sum_{j=0}^{i-k}{\binom{i}{j+k}\binom{j+k}{k}(-1)^j}\\ = & \sum_{j=0}^{i-k}\frac{i^{\underline{j+k}}(j+k)^{\underline{k}}}{(j+k)!k!}(-1)^j\\ = & \sum_{j=0}^{i-k}\frac{i^{\underline{k}}(i-k)^{\underline{j}}(j+k)^{\underline{k}}}{k!(j+k)^{\underline{k}}j!}(-1)^j\\ = & \binom{i}{k}\sum_{j=0}^{i-k}\frac{(i-k)^{\underline{j}}}{j!}(-1)^j\\ = & \binom{i}{k}\sum_{j=0}^{i-k}\binom{i-k}{j}(-1)^j\\ = & [i-k==0]\\ = & [i==k] \end{aligned} =========j=0i(ji)α(j)j=0i(ji)(kj)(1)jkj=ki(ji)(kj)(1)jkj=0ik(j+ki)(kj+k)(1)jj=0ik(j+k)!k!ij+k(j+k)k(1)jj=0ikk!(j+k)kj!ik(ik)j(j+k)k(1)j(ki)j=0ikj!(ik)j(1)j(ki)j=0ik(jik)(1)j[ik==0][i==k]
实际上丢二项式反演好用(雾
f ( n ) = ∑ i = 0 n g ( i ) ( n i ) ⟺ g ( n ) = ∑ i = 0 n ( − 1 ) n − i ( n i ) f ( i ) f(n) = \sum_{i = 0}^{n}{g(i)\binom{n}{i}} \Longleftrightarrow g(n) = \sum_{i = 0}^n{(-1)^{n-i}\binom{n}{i}f(i)} f(n)=i=0ng(i)(in)g(n)=i=0n(1)ni(in)f(i)

证明

g ( n ) = ∑ i = 0 n ( − 1 ) n − i ( n i ) ∑ j = 0 i g ( j ) ( i j ) = ∑ j = 0 n g ( j ) ∑ i = j n ( − 1 ) n − i ( n i ) ( i j ) = ∑ j = 0 n g ( j ) ∑ i = j n ( − 1 ) n − i ( n j ) ( n − j i − j ) = ∑ j = 0 n g ( j ) ( n j ) ∑ i = j n ( − 1 ) n − i ( n − j i − j ) = ∑ j = 0 n g ( j ) ( n j ) ( − 1 + 1 ) n − j = ( n n ) g ( n ) = g ( n ) \begin{aligned} g(n) =& \sum_{i = 0}^n{(-1)^{n-i}\binom{n}{i} \sum_{j = 0}^{i}{g(j) \binom{i}{j}}}\\ =& \sum_{j = 0}^n{g(j) \sum_{i = j}^{n}{(-1)^{n - i} \binom{n}{i}\binom{i}{j} }}\\ =& \sum_{j = 0}^n{g(j)\sum_{i = j}^{n}{(-1)^{n - i}\binom{n}{j} \binom{n - j}{i - j}}}\\ =& \sum_{j = 0}^n{g(j)\binom{n}{j}\sum_{i = j}^{n}{(-1)^{n - i}\binom{n - j}{i - j}}}\\ =& \sum_{j = 0}^n{g(j)\binom{n}{j}(-1+1)^{n-j}}\\ =& \binom{n}{n}g(n) \\ =&g(n)\\ \end{aligned} g(n)=======i=0n(1)ni(in)j=0ig(j)(ji)j=0ng(j)i=jn(1)ni(in)(ji)j=0ng(j)i=jn(1)ni(jn)(ijnj)j=0ng(j)(jn)i=jn(1)ni(ijnj)j=0ng(j)(jn)(1+1)nj(nn)g(n)g(n)
所以这个是正确的。

意义:(先证明再说意义还行

f ( n ) f(n) f(n)一般情况下代表至多满足 n n n个条件的方案数,对应地, g ( n ) g(n) g(n)表示恰好满足 n n n个条件的方案数。

当然有时候其实是反过来的,定义 f ( i ) f(i) f(i)是至少满足 i i i个约束的方案数, g ( n ) g(n) g(n)是恰满

n n n个约束的方案数,那么:

g ( k ) = ∑ i = k n ( − 1 ) i − k ( i k ) f ( i ) g(k)=\sum_{i=k}^n{(-1)^{i-k}\binom{i}{k}f(i)} g(k)=i=kn(1)ik(ki)f(i)

证明就是一开始提到的构造容斥系数 α ( j ) \alpha(j) α(j)那一坨

暴力带回去说是对的不就行了管他咋构造出来的

你可能感兴趣的:(结论证明,性质分析,二项式反演,容斥原理)