前置知识
1.牛顿二项式定理
( x + y ) n = ∑ k = 0 n ( n k ) x n − k y k (x+y)^n=\sum\limits_{k=0}^n\tbinom{n}{k}x^{n-k}y^k (x+y)n=k=0∑n(kn)xn−kyk
常见的:
( 1 + x ) n = ∑ k = 0 ∞ C n k x k (1+x)^n=\sum\limits_{k=0}^{\infty}C_n^kx^k (1+x)n=k=0∑∞Cnkxk
推广到 − n -n −n为负数:
( 1 + x ) − n = ∑ k = 0 ∞ C − n k x k = ∑ k = 0 ∞ ( − 1 ) k C n + k − 1 k x k (1+x)^{-n}=\sum\limits_{k=0}^{\infty}C_{-n}^kx^k=\sum\limits_{k=0}^{\infty}(-1)^kC_{n+k-1}^kx^k (1+x)−n=k=0∑∞C−nkxk=k=0∑∞(−1)kCn+k−1kxk
1 ( 1 − x ) n = ( 1 + ( − x ) ) − n = ∑ k = 0 ∞ ( − 1 ) k C n + k − 1 k ( − x ) k = ∑ k = 0 ∞ C n + k − 1 k x k \dfrac{1}{(1-x)^n}=(1+(-x))^{-n}=\sum\limits_{k=0}^{\infty}(-1)^kC_{n+k-1}^k(-x)^k=\sum\limits_{k=0}^{\infty}C_{n+k-1}^kx^k (1−x)n1=(1+(−x))−n=k=0∑∞(−1)kCn+k−1k(−x)k=k=0∑∞Cn+k−1kxk
1 1 − x = ∑ n = 0 x n \dfrac{1}{1-x}=\sum\limits_{n=0}x^n 1−x1=n=0∑xn
1 1 − x a = ∑ n = 0 ( x a ) n \dfrac{1}{1-x^a}=\sum\limits_{n=0}(x^a)^n 1−xa1=n=0∑(xa)n
1 1 − a x = ∑ n = 0 ( a x ) n \dfrac{1}{1-ax}=\sum\limits_{n=0}(ax)^n 1−ax1=n=0∑(ax)n
2.牛顿广义二项式定理
( x + y ) α = ∑ k = 0 ∞ ( α k ) x α − k y k (x+y)^\alpha=\sum\limits_{k=0}^{\infty}\tbinom{\alpha}{k}x^{\alpha-k}y^k (x+y)α=k=0∑∞(kα)xα−kyk
( α k ) = α ( α − 1 ) … ( α − k + 1 ) k ! \tbinom{\alpha}{k}=\dfrac{\alpha(\alpha-1)\dots(\alpha-k+1)}{k!} (kα)=k!α(α−1)…(α−k+1)
生成函数
源于Wiki
看懂定义后。
来举个例子:
a
=
{
1
,
1
,
1
,
1
…
}
⇒
f
(
x
)
=
1
+
x
+
x
2
+
x
3
+
…
=
∑
n
=
0
x
n
=
1
1
−
x
a=\{1,1,1,1\dots\}\Rightarrow f(x)=1+x+x^2+x^3+\dots\\=\sum\limits_{n=0}x^n=\dfrac{1} {1-x}
a={1,1,1,1…}⇒f(x)=1+x+x2+x3+…=n=0∑xn=1−x1 (这里可以用等比数列求和公式,或者直接泰勒级数可得)
这里的序列 a i a_i ai, i ( 从 0 开 始 ) i(从0开始) i(从0开始)对应的 x i x^i xi的系数。
即: a = { a 0 , a 1 , a 2 , a 3 … } , f ( x ) = ∑ n = 0 a n x n a=\{a_0,a_1,a_2,a_3\dots\},f(x)=\sum\limits_{n=0}a_nx^n a={a0,a1,a2,a3…},f(x)=n=0∑anxn
a = { 1 , 1 , 1 , 1 … } ⏟ n 个 1 ⇒ f ( x ) = 1 + x + x 2 + x 3 + ⋯ + x n − 1 = 1 − x n 1 − x a=\underbrace{\{1,1,1,1\dots\}}_{n个1}\Rightarrow f(x)=1+x+x^2+x^3+\dots+x^{n-1}=\dfrac{1-x^n}{1-x} a=n个1 {1,1,1,1…}⇒f(x)=1+x+x2+x3+⋯+xn−1=1−x1−xn
利用母函数求解 f i b o n a c c i fibonacci fibonacci数列通项公式
a = { 0 , 1 , 1 , 2 , 3 , 5 , 8 … } ⇒ f ( x ) = x + x 2 + 2 x 3 + 3 x 4 + 5 x 5 … a=\{0,1,1,2,3,5,8\dots\}\Rightarrow f(x)=x+x^2+2x^3+3x^4+5x^5\dots a={0,1,1,2,3,5,8…}⇒f(x)=x+x2+2x3+3x4+5x5…
f ( x ) − x f ( x ) = ( x + x 2 + 2 x 3 + 3 x 4 … ) − ( x 2 + x 3 + 2 x 4 + 3 x 5 … ) = x + ( x 3 + x 4 + 2 x 5 … ) = x + x 2 f ( x ) ⇒ f ( x ) = x 1 − x − x 2 f(x)-xf(x)\\=(x+x^2+2x^3+3x^4\dots)-(x^2+x^3+2x^4+3x^5\dots)=x+(x^3+x^4+2x^5\dots)=x+x^2f(x)\\ \Rightarrow f(x)=\dfrac{x}{1-x-x^2} f(x)−xf(x)=(x+x2+2x3+3x4…)−(x2+x3+2x4+3x5…)=x+(x3+x4+2x5…)=x+x2f(x)⇒f(x)=1−x−x2x
f
(
x
)
=
x
(
1
−
1
−
5
2
x
)
(
1
−
1
+
5
2
x
)
f(x)=\dfrac{x}{(1-\dfrac{1-\sqrt{5}}{2}x)(1-\dfrac{1+\sqrt{5}}{2}x)}
f(x)=(1−21−5
x)(1−21+5
x)x
令
p
=
(
1
−
1
−
5
2
x
)
,
q
=
(
1
−
1
+
5
2
x
)
,
q
−
p
=
−
5
x
p=(1-\dfrac{1-\sqrt{5}}{2}x),q=(1-\dfrac{1+\sqrt{5}}{2}x),q-p=-\sqrt{5}x
p=(1−21−5
x),q=(1−21+5
x),q−p=−5
x
f ( x ) = x p q = x ( 1 p − 1 q ) 1 q − p f(x)=\dfrac{x}{pq}=x(\dfrac{1}{p}-\dfrac{1}{q})\dfrac{1}{q-p} f(x)=pqx=x(p1−q1)q−p1
f ( x ) = − 1 5 ( 1 p − 1 q ) = 1 5 ( 1 q − 1 p ) f(x)=\dfrac{-1}{\sqrt{5}}(\dfrac{1}{p}-\dfrac{1}{q})=\dfrac{1}{\sqrt{5}}(\dfrac{1}{q}-\dfrac{1}{p}) f(x)=5 −1(p1−q1)=5 1(q1−p1)
1
q
=
1
1
−
1
+
5
2
x
→
\dfrac{1}{q}=\dfrac{1}{1-\dfrac{1+\sqrt{5}}{2}x}\rightarrow
q1=1−21+5
x1→ 对应生成函数
f
q
(
x
)
=
∑
n
=
0
(
1
+
5
2
x
)
n
f_q(x)=\sum\limits_{n=0} (\dfrac{1+\sqrt{5}}{2}x)^n
fq(x)=n=0∑(21+5
x)n
同理:
f
p
(
x
)
=
∑
n
=
0
(
1
−
5
2
x
)
n
f_p(x)=\sum\limits_{n=0} (\dfrac{1-\sqrt{5}}{2}x)^n
fp(x)=n=0∑(21−5
x)n
所以 f ( x ) = 1 5 ( f q ( x ) − f p ( x ) ) = ∑ n = 0 x n 1 5 ( ( 1 + 5 2 ) n − ( 1 − 5 2 ) n ) f(x)=\dfrac{1}{\sqrt{5}}(f_q(x)-f_p(x))\\=\sum\limits_{n=0}x^n\dfrac{1}{\sqrt{5}}((\dfrac{1+\sqrt{5}}{2})^n-(\dfrac{1-\sqrt{5}}{2})^n) f(x)=5 1(fq(x)−fp(x))=n=0∑xn5 1((21+5 )n−(21−5 )n)
所以
F
n
=
1
5
(
(
1
+
5
2
)
n
−
(
1
−
5
2
)
n
)
F_n=\dfrac{1}{\sqrt{5}}((\dfrac{1+\sqrt{5}}{2})^n-(\dfrac{1-\sqrt{5}}{2})^n)
Fn=5
1((21+5
)n−(21−5
)n)
来个例题:
1.牛客S2巅峰赛11th-B.挑选方案问题
a
1
=
{
1
,
1
,
1
…
}
=
∑
n
=
0
x
n
=
1
1
−
x
a_1=\{1,1,1\dots\}=\sum\limits_{n=0}x^n=\dfrac{1}{1-x}
a1={1,1,1…}=n=0∑xn=1−x1
a
2
=
{
1
,
1
}
=
1
+
x
=
1
−
x
2
1
−
x
a_2=\{1,1\}=1+x=\dfrac{1-x^2}{1-x}
a2={1,1}=1+x=1−x1−x2
a
3
=
{
1
,
1
,
1
,
1
,
1
}
=
1
+
x
+
x
2
+
x
3
+
x
4
=
1
−
x
5
1
−
x
a_3=\{1,1,1,1,1\}=1+x+x^2+x^3+x^4=\dfrac{1-x^5}{1-x}
a3={1,1,1,1,1}=1+x+x2+x3+x4=1−x1−x5
a
4
=
{
1
,
0
,
1
,
0
,
1
…
}
=
∑
n
=
0
x
2
n
=
1
1
−
x
2
a_4=\{1,0,1,0,1\dots\}=\sum\limits_{n=0}x^{2n}=\dfrac{1}{1-x^{2}}
a4={1,0,1,0,1…}=n=0∑x2n=1−x21
a
5
=
{
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
…
}
=
∑
n
=
0
x
5
n
=
1
1
−
x
5
a_5=\{1,0,0,0,0,1,0,0,0,0,1\dots\}=\sum\limits_{n=0}x^{5n}=\dfrac{1}{1-x^5}
a5={1,0,0,0,0,1,0,0,0,0,1…}=n=0∑x5n=1−x51
卷积得:
f
(
x
)
=
1
1
−
x
×
1
−
x
2
1
−
x
×
1
−
x
5
1
−
x
×
1
1
−
x
2
×
1
1
−
x
5
=
1
(
1
−
x
)
3
=
∑
n
=
0
C
n
+
2
n
x
n
f(x)=\dfrac{1}{1-x}\times \dfrac{1-x^2}{1-x}\times \dfrac{1-x^5}{1-x}\times\dfrac{1}{1-x^{2}}\times\dfrac{1}{1-x^5}=\dfrac{1}{(1-x)^3}=\sum\limits_{n=0}C_{n+2}^n x^n
f(x)=1−x1×1−x1−x2×1−x1−x5×1−x21×1−x51=(1−x)31=n=0∑Cn+2nxn
所以 a n s = C n + 2 n = ( n + 1 ) ( n + 2 ) 2 ans=C_{n+2}^n=\dfrac{(n+1)(n+2)}{2} ans=Cn+2n=2(n+1)(n+2)
待更 … … \dots\dots ……