排列数(又称下降阶乘幂)
n m ‾ = n ( n − 1 ) ( n − 2 ) . . . . ( n − m + 1 ) = A n m n^{\underline m} = n(n-1)(n-2)....(n-m+1)=A_n^m nm=n(n−1)(n−2)....(n−m+1)=Anm
下降幂的差分
下降幂的差分具有良好的性质
Δ
n
k
‾
=
(
n
+
1
)
k
‾
−
n
k
=
k
∗
n
k
−
1
‾
\Delta n^{\underline k}=(n+1)^{\underline k} - n^k=k*n^{\underline {k-1}}
Δnk=(n+1)k−nk=k∗nk−1(展开合并即可)
前缀和是查分的逆运算也具有良好的性质:
∑
i
k
‾
=
∑
0
≤
i
<
n
i
k
‾
=
1
k
+
1
n
k
+
1
‾
\sum i^{\underline k} = \sum_{0\le i <n } i^{\underline k} = \frac{1}{k+1} n^{\underline {k+1}}
∑ik=0≤i<n∑ik=k+11nk+1
证明:
①:转换到组合意义
∑
0
≤
i
<
n
i
k
‾
=
∑
0
≤
i
<
n
A
i
k
=
1
k
!
∑
0
≤
i
<
n
(
i
k
)
=
1
k
!
∗
C
n
k
+
1
=
1
k
!
∗
n
!
(
k
+
1
)
!
(
n
−
k
−
1
)
!
=
1
k
+
1
∗
n
!
n
−
j
−
1
!
=
1
k
+
1
A
n
k
+
1
=
1
k
+
1
n
k
+
1
‾
\sum_{0 \le i<n} i^{\underline k} = \sum_{0 \le i<n} A_i^k = \frac{1}{k!} \sum_{0 \le i<n} {i \choose k} \\ =\frac{1}{k!} *C_{n}^{k+1}=\frac{1}{k!}*\frac{n!}{(k+1)!(n-k-1)!}\\ =\frac{1}{k+1}*\frac{n!}{n-j-1!}=\frac{1}{k+1}A_n^{k+1} =\frac{1}{k+1}n^{\underline {k+1}}
0≤i<n∑ik=0≤i<n∑Aik=k!10≤i<n∑(ki)=k!1∗Cnk+1=k!1∗(k+1)!(n−k−1)!n!=k+11∗n−j−1!n!=k+11Ank+1=k+11nk+1
②:直接通过下降幂的查分
n
k
+
1
‾
=
∑
i
=
0
n
−
1
Δ
i
k
‾
=
(
k
+
1
)
∑
i
=
0
n
−
1
i
k
‾
⇒
∑
i
=
0
n
−
1
i
k
‾
=
1
k
+
1
n
k
+
1
‾
n^{\underline {k+1}} = \sum_{i=0}^{n-1}\Delta i^{\underline k}=(k+1)\sum_{i=0}^{n-1}i^{\underline k}\\ \Rightarrow \sum_{i=0}^{n-1}i^{\underline k}=\frac{1}{k+1}n^{\underline{k+1}}
nk+1=i=0∑n−1Δik=(k+1)i=0∑n−1ik⇒i=0∑n−1ik=k+11nk+1
牛顿二项式定理
( 1 + z ) r = ∑ k ( r k ) z k (1+z)^r=\sum_{k} {r \choose k} z^k (1+z)r=k∑(kr)zk
常见的组合数恒等式
吸收/提取恒等式:
(
n
m
)
=
n
m
(
n
−
1
m
−
1
)
⇒
m
(
n
m
)
=
n
(
n
−
1
m
−
1
)
{n\choose m}=\frac{n}{m}{n-1\choose m-1}\Rightarrow m{n \choose m} = n{n-1 \choose m-1}
(mn)=mn(m−1n−1)⇒m(mn)=n(m−1n−1)
证明显然
翻转上指标恒等式:
(
n
m
)
=
(
−
1
)
m
(
m
−
n
−
1
m
)
{n\choose m} = (-1)^m{m-n-1 \choose m}
(mn)=(−1)m(mm−n−1)
证明:展开后将分子取反即可
三项式版恒等式:
(
n
m
)
(
m
k
)
=
(
n
k
)
(
n
−
k
m
−
k
)
{n\choose m}{m \choose k} = {n\choose k}{n-k \choose m-k}
(mn)(km)=(kn)(m−kn−k)
证明:考虑组合意义
平行求和:
∑
k
≤
n
(
r
+
k
k
)
=
(
r
+
n
+
1
n
)
\sum_{k\le n}{r+k \choose k} = {r+n+1 \choose n}
k≤n∑(kr+k)=(nr+n+1)
将第一项变换后两两合并即可
上指标求和:
∑
k
≤
n
(
k
m
)
=
(
n
+
1
m
+
1
)
\sum_{k\le n} {k \choose m} = {n+1 \choose m+1}
k≤n∑(mk)=(m+1n+1)
证明:考虑组合意义
从
n
+
1
n+1
n+1个球挑出
m
+
1
m+1
m+1个球,
(
k
m
)
{k\choose m}
(mk)表示最大标号为k的方案数,即可推得
范德蒙德卷积恒等式
∑
k
(
r
k
)
(
s
n
−
k
)
=
(
r
+
s
n
)
\sum_k{r\choose k}{s\choose n-k}={r+s\choose n}
k∑(kr)(n−ks)=(nr+s)
证明:考虑组合意义
两个大小分别为
r
r
r和
s
s
s的集合,总共要挑出
n
n
n个元素
容斥原理
基于恒等式:
∑
k
=
0
(
−
1
)
k
(
n
k
)
=
[
n
=
=
0
]
\sum_{k=0} (-1)^k{n\choose k}=[n==0]
k=0∑(−1)k(kn)=[n==0]
简单变形:
∑
k
≥
1
(
−
1
)
k
(
n
k
)
=
[
n
>
0
]
\sum_{k\ge 1}(-1)^{k}{n\choose k}=[n>0]
k≥1∑(−1)k(kn)=[n>0]
一般情形:
∣
⋃
i
∈
I
A
i
∣
=
∑
α
⊆
I
(
−
1
)
∣
α
+
1
∣
∣
⋂
i
∈
α
A
i
∣
\left| \bigcup_{i∈I} A_i \right| = \sum_{\alpha \subseteq I}(-1)^{|\alpha+1|} \left| \bigcap_{i∈\alpha} A_i \right|
∣∣∣∣∣i∈I⋃Ai∣∣∣∣∣=α⊆I∑(−1)∣α+1∣∣∣∣∣∣i∈α⋂Ai∣∣∣∣∣
证明:考虑每个元素的出现集合
S
x
=
{
i
∣
x
∈
A
i
}
S_x=\{i|x∈A_i\}
Sx={i∣x∈Ai},那么原式等价求
∑
x
[
S
x
>
0
]
\sum_x[S_x>0]
∑x[Sx>0]
考虑
x
x
x被算了几次
,对于
S
x
S_x
Sx的任何一个子集
s
s
s,
x
x
x都被加上了
(
−
1
)
∣
s
∣
+
1
(-1)^{|s|+1}
(−1)∣s∣+1的贡献,故x被计算的次数为
∑
k
≥
1
(
−
1
)
k
+
1
(
∣
S
x
∣
k
)
=
[
∣
S
x
∣
>
0
]
\sum_{k\ge 1}(-1)^{k+1} { |S_x| \choose k }=[|S_x|>0]
∑k≥1(−1)k+1(k∣Sx∣)=[∣Sx∣>0]
容斥原理的另一种形式:
∣
⋂
i
A
‾
i
∣
=
∑
α
∈
I
(
−
1
)
α
∣
⋂
i
∈
α
A
i
∣
\left| \bigcap_i \overline A_i \right|=\sum_{\alpha ∈I}(-1)^{\alpha}\left| \bigcap_{i∈\alpha} A_i \right|
∣∣∣∣∣i⋂Ai∣∣∣∣∣=α∈I∑(−1)α∣∣∣∣∣i∈α⋂Ai∣∣∣∣∣
前半部分显然是求并集的补集,只要在对原来的式子取反即可
min-max容斥
记
m
a
x
(
S
)
max(S)
max(S)为集合
S
S
S中最大的元素的值
记
m
i
n
(
S
)
min(S)
min(S)为集合
S
S
S中最小的元素的值
有
m
a
x
(
S
)
=
∑
A
⊆
S
且
A
≠
ϕ
(
−
1
)
∣
A
∣
−
1
m
i
n
(
A
)
max(S)=\sum_{A\subseteq S且A≠\phi} (-1)^{|A|-1}min(A)
max(S)=∑A⊆S且A̸=ϕ(−1)∣A∣−1min(A)
证明:
记
S
x
S_x
Sx为比
x
x
x元素大的元素集合
则
x
x
x的贡献为:
∑
k
(
∣
S
x
∣
k
)
(
−
1
)
k
=
[
∣
S
x
∣
=
ϕ
]
\sum_k{|S_x| \choose k}(-1)^k=[|S_x|=\phi]
k∑(k∣Sx∣)(−1)k=[∣Sx∣=ϕ]
拓展形式: l c m ( S ) = ∑ A ⊆ S 且 A ≠ ϕ ( − 1 ) ∣ A ∣ − 1 g c d ( A ) lcm(S)=\sum_{A\subseteq S且A≠\phi} (-1)^{|A|-1}gcd(A) lcm(S)=∑A⊆S且A̸=ϕ(−1)∣A∣−1gcd(A)
二项式反演
g
(
n
)
=
∑
k
(
−
1
)
k
(
n
k
)
f
(
k
)
⇔
f
(
n
)
=
∑
k
(
−
1
)
k
(
n
k
)
g
(
k
)
g
(
n
)
=
∑
k
(
n
k
)
f
(
k
)
⇔
f
(
n
)
=
∑
k
(
−
1
)
n
−
k
(
n
k
)
g
(
k
)
g(n)=\sum_k (-1)^k{n\choose k}f(k)\Leftrightarrow f(n)=\sum_k(-1)^k{n\choose k}g(k)\\ g(n)=\sum_k{n\choose k}f(k)\Leftrightarrow f(n)=\sum_k (-1)^{n-k}{n\choose k}g(k)
g(n)=k∑(−1)k(kn)f(k)⇔f(n)=k∑(−1)k(kn)g(k)g(n)=k∑(kn)f(k)⇔f(n)=k∑(−1)n−k(kn)g(k)
证明:
首先对于①式
∑
k
(
−
1
)
k
(
n
k
)
∑
j
(
−
1
)
j
(
k
j
)
g
(
j
)
=
∑
j
(
−
1
)
j
∑
k
(
−
1
)
k
(
n
k
)
(
k
j
)
=
∑
j
(
−
1
)
j
∑
k
(
−
1
)
k
(
n
j
)
(
n
−
j
k
−
j
)
=
∑
j
(
n
j
)
g
(
j
)
∑
k
(
−
1
)
k
(
n
−
j
k
)
=
∑
j
(
n
j
)
g
(
j
)
[
n
=
j
]
=
g
(
n
)
\sum_k (-1)^k {n\choose k} \sum_j(-1)^j{k\choose j} g(j)\\ = \sum_j (-1)^j \sum_k (-1)^k {n\choose k}{k\choose j}\\ = \sum_j (-1)^j \sum_k (-1)^k {n\choose j}{n-j\choose k-j}\\ = \sum_j {n\choose j}g(j) \sum_k (-1)^{k} {n-j\choose k}\\ = \sum_j {n\choose j}g(j) [ n = j ]\\ = g(n)
k∑(−1)k(kn)j∑(−1)j(jk)g(j)=j∑(−1)jk∑(−1)k(kn)(jk)=j∑(−1)jk∑(−1)k(jn)(k−jn−j)=j∑(jn)g(j)k∑(−1)k(kn−j)=j∑(jn)g(j)[n=j]=g(n)
二式同理
我们考虑从母函数的角度去证明这个式子:
g
(
n
)
=
∑
k
(
−
1
)
k
(
n
k
)
f
(
k
)
g
(
n
)
=
∑
k
(
−
1
)
k
n
!
(
n
−
k
)
!
k
!
f
(
k
)
g
(
n
)
n
!
=
∑
k
(
−
1
)
k
f
(
k
)
k
!
1
(
n
−
k
)
!
(
∑
n
(
−
1
)
n
f
(
n
)
n
!
z
n
)
×
(
∑
n
1
n
!
z
n
)
G
e
(
z
)
=
F
e
(
−
z
)
e
z
G
e
(
z
)
e
−
z
=
F
e
(
−
z
)
F
e
(
z
)
=
G
e
(
−
z
)
e
z
f
(
n
)
/
n
!
=
∑
k
(
−
1
)
k
g
(
k
)
k
!
×
1
(
n
−
k
)
!
f
(
n
)
=
∑
k
(
−
1
)
k
(
n
k
)
g
(
k
)
g(n) = \sum_k (-1)^k {n\choose k} f(k) \\ g(n) = \sum_k (-1)^k \frac{n!}{(n-k)!k!} f(k)\\ \frac{g(n)}{n!}=\sum_k(-1)^k \frac{f(k)}{k!} \frac{1}{(n-k)!}\\ \left(\sum_n (-1)^n \frac{f(n)}{n!} z^n\right) \times \left(\sum_n \frac{1}{n!} z^n\right)\\ G_e(z) = F_e(-z) e^z\\ G_e(z) e^{-z} = F_e(-z)\\ F_e(z) = G_e(-z) e^{z}\\ f(n)/n! = \sum_k (-1)^k\frac{g(k)}{k!}\times \frac{1}{(n-k)!}\\ f(n) = \sum_k(-1)^k{n\choose k}g(k)
g(n)=k∑(−1)k(kn)f(k)g(n)=k∑(−1)k(n−k)!k!n!f(k)n!g(n)=k∑(−1)kk!f(k)(n−k)!1(n∑(−1)nn!f(n)zn)×(n∑n!1zn)Ge(z)=Fe(−z)ezGe(z)e−z=Fe(−z)Fe(z)=Ge(−z)ezf(n)/n!=k∑(−1)kk!g(k)×(n−k)!1f(n)=k∑(−1)k(kn)g(k)
第二个式子更简单:
g
(
n
)
=
∑
k
(
n
k
)
f
(
k
)
  
⟺
  
f
(
n
)
=
∑
k
(
n
k
)
(
−
1
)
n
−
k
g
(
k
)
g
(
n
)
n
!
=
∑
k
f
(
k
)
k
!
1
(
n
−
k
)
!
G
(
z
)
=
F
(
z
)
e
z
⇒
F
(
z
)
=
G
(
z
)
e
−
z
f
(
n
)
=
∑
k
g
(
k
)
(
−
1
)
n
−
k
(
n
−
k
)
!
g(n) = \sum_k{n\choose k}f(k) \iff f(n) = \sum_k{n\choose k}(-1)^{n-k}g(k)\\ \frac{g(n)}{n!} = \sum_k \frac{f(k)}{k!} \frac{1}{(n-k)!}\\ G(z)=F(z)e^z \Rightarrow F(z)=G(z)e^{-z} \\ f(n) = \sum_kg(k)\frac{(-1)^{n-k}}{(n-k)!}
g(n)=k∑(kn)f(k)⟺f(n)=k∑(kn)(−1)n−kg(k)n!g(n)=k∑k!f(k)(n−k)!1G(z)=F(z)ez⇒F(z)=G(z)e−zf(n)=k∑g(k)(n−k)!(−1)n−k
卡特兰数
多的就不讲了,讲一下通项推导 https://blog.csdn.net/a1035719430/article/details/85078446
广义容斥原理
α
\alpha
α是指标集,设
f
(
α
)
f(\alpha)
f(α)表示不被
⋃
i
∈
α
A
i
\bigcup_{i∈\alpha}A_i
⋃i∈αAi且被
⋂
i
∉
α
A
i
\bigcap_{i\notin \alpha}A_i
⋂i∈/αAi包含的元素个数,
g
(
α
)
g(\alpha)
g(α)表示不被
⋃
i
∈
α
\bigcup_{i\in\alpha}
⋃i∈α包含的元素个数
则有递推关系:
f
(
α
)
=
g
(
α
)
−
∑
α
⊆
γ
,
α
≠
γ
f
(
γ
)
f(\alpha)=g(\alpha)-\sum_{\alpha \subseteq \gamma ,\alpha ≠\gamma}f(\gamma)
f(α)=g(α)−α⊆γ,α̸=γ∑f(γ)
很多问题要求恰好在
k
k
k个集合中的元素个数(恰好满足
k
k
k个性质)
设其为
f
(
k
)
f(k)
f(k),同时设
g
(
k
)
g(k)
g(k)表示至少在
k
k
k个集合的方案数,先然后
f
(
i
)
=
g
(
i
)
−
∑
k
>
i
(
k
i
)
f
(
k
)
f(i)=g(i)-\sum_{k>i}{k\choose i}f(k)
f(i)=g(i)−k>i∑(ik)f(k)
例题:bzoj3622
传送门:https://blog.csdn.net/a1035719430/article/details/84955309
广义容斥的优秀做法
广义容斥还有
O
(
n
l
o
g
n
)
O(nlogn)
O(nlogn)的解法
g
(
i
)
=
∑
k
(
k
i
)
f
(
k
)
=
∑
k
k
!
f
(
k
)
i
!
(
k
−
i
)
!
⇒
i
!
g
(
i
)
=
∑
k
k
!
f
(
k
)
(
k
−
i
)
!
g(i)=\sum_{k}{k\choose i}f(k)=\sum_k \frac{k!f(k)}{i!(k-i)!}\\ \Rightarrow i!g(i)=\sum_k \frac{k!f(k)}{(k-i)!}
g(i)=k∑(ik)f(k)=k∑i!(k−i)!k!f(k)⇒i!g(i)=k∑(k−i)!k!f(k)
令
G
(
i
)
=
(
N
−
i
)
!
g
(
N
−
i
)
,
F
(
i
)
=
(
N
−
i
)
!
f
(
N
−
i
)
!
G(i)=(N-i)!g(N-i),F(i)=(N-i)!f(N-i)!
G(i)=(N−i)!g(N−i),F(i)=(N−i)!f(N−i)!