第一类斯特林数
[large egin{bmatrix}n\ mend{bmatrix}=(n-1)egin{bmatrix}n-1\ mend{bmatrix}+egin{bmatrix}n-1\ m-1end{bmatrix}
]
其为将 (n) 个元素划分为 (m) 个轮换的方案数。递推式即为考虑最后一个元素是否作为一个新轮换。
(egin{bmatrix}n\ iend{bmatrix}) 是恰好有 (i) 个轮换的排列数,因此有:
[large sum_{i=0}^n egin{bmatrix}n\ iend{bmatrix}=n!
]
与幂的关系:
[large x^{overline{n}}=sum_{i=0}^negin{bmatrix}n\ iend{bmatrix}x^i
]
归纳法证明:
[largeegin{aligned}
x^{overline{n-1}}&=sum_{i=0}^{n-1}egin{bmatrix}n-1\ iend{bmatrix}x^i \
(x+n-1)x^{overline{n-1}}&=(x+n-1)sum_{i=0}^{n-1}egin{bmatrix}n-1\ iend{bmatrix}x^i \
x^{overline{n}}&=(n-1)sum_{i=0}^{n-1}egin{bmatrix}n-1\ iend{bmatrix}x^i+sum_{i=1}^{n}egin{bmatrix}n-1\ i-1end{bmatrix}x^i \
x^{overline{n}}&=sum_{i=0}^{n}egin{bmatrix}n\ iend{bmatrix}x^i \
end{aligned}
]
考虑将 (x^{overline{n}} = (-1)^n(-x)^{underline{n}}) 代入到 (x^{overline{n}}=sumlimits_{i=0}^negin{bmatrix}n\ iend{bmatrix}x^i) 中,并将 (x) 换为 (-x),得:
[largeegin{aligned}
(-1)^nx^{underline{n}} &= sumlimits_{i=0}^negin{bmatrix}n\ iend{bmatrix}(-x)^i \
x^{underline{n}} &= sumlimits_{i=0}^n(-1)^{n-i}egin{bmatrix}n\ iend{bmatrix}x^i \
end{aligned}
]
第二类斯特林数
[large egin{Bmatrix} n \m end{Bmatrix}=megin{Bmatrix} n-1 \m end{Bmatrix}+egin{Bmatrix} n-1 \m-1 end{Bmatrix}
]
其为将 (n) 个元素划分为 (m) 个集合的方案数。递推式即为考虑最后一个元素是否作为一个新集合。
与幂的关系:
[large x^n = sum_{i=0}^n egin{Bmatrix} n \i end{Bmatrix} x^{underline{i}}
]
归纳法证明:
[largeegin{aligned}
large x^{n-1} &= sum_{i=0}^{n-1} egin{Bmatrix} n-1 \i end{Bmatrix} x^{underline{i}} \
large x^n &= xsum_{i=0}^{n-1} egin{Bmatrix} n-1 \i end{Bmatrix} x^{underline{i}} \
large x^n &= sum_{i=0}^{n-1} egin{Bmatrix} n-1 \i end{Bmatrix} ix^{underline{i}} +sum_{i=0}^{n-1} egin{Bmatrix} n-1 \i end{Bmatrix} (x-i)x^{underline{i}} \
large x^n &= sum_{i=0}^{n-1} egin{Bmatrix} n-1 \i end{Bmatrix} ix^{underline{i}} +sum_{i=1}^n egin{Bmatrix} n-1 \i-1 end{Bmatrix} x^{underline{i}} \
large x^n &= sum_{i=0}^n egin{Bmatrix} n \i end{Bmatrix} x^{underline{i}} \
end{aligned}
]
考虑将 (x^{underline{n}} = (-1)^n(-x)^{overline{n}}) 代入到 (x^n = sumlimits_{i=0}^n egin{Bmatrix} n \i end{Bmatrix} x^{underline{i}}) 中,并将 (x) 换为 (-x),得:
[largeegin{aligned}
large (-x)^n &= sum_{i=0}^n (-1)^iegin{Bmatrix} n \i end{Bmatrix} x^{overline{i}} \
large x^n &= sum_{i=0}^n (-1)^{n-i}egin{Bmatrix} n \i end{Bmatrix} x^{overline{i}} \
end{aligned}
]
关系
反转公式:
[largeegin{aligned}
sum_{i=m}^n(-1)^{n-i}egin{bmatrix}n\ iend{bmatrix}egin{Bmatrix}i\ mend{Bmatrix}=[n=m] \
sum_{i=m}^n(-1)^{n-i}egin{Bmatrix}n\ iend{Bmatrix}egin{bmatrix}i\ mend{bmatrix}=[n=m] \
end{aligned}
]
证明:
[largeegin{aligned}
m^{underline n}&=sumlimits_{i=0}^n(-1)^{n-i} egin{bmatrix}n\iend{bmatrix}m^i\
&=sumlimits_{i=0}^n (-1)^{n-i} egin{bmatrix}n\iend{bmatrix}sumlimits_{j=0}^i egin{Bmatrix}i\jend{Bmatrix}m^{underline j}\
&=sumlimits_{i=0}^n m^{underline i}sumlimits_{j=i}^n (-1)^{n-j} egin{bmatrix}n\jend{bmatrix} egin{Bmatrix}j\iend{Bmatrix} \
m^n&=sumlimits_{i=0}^n(-1)^{n-i}egin{Bmatrix}n\iend{Bmatrix}m^{overline i}\
&=sumlimits_{i=0}^n(-1)^{n-i}egin{Bmatrix}n\iend{Bmatrix}sumlimits_{j=0}^i egin{bmatrix}i\jend{bmatrix}m^j\
&=sumlimits_{i=0}^n m^isumlimits_{j=i}^n(-1)^{n-j} egin{Bmatrix}n\jend{Bmatrix}egin{bmatrix}j\iend{bmatrix}
end{aligned}
]
斯特林反演:
[large f(n)=sumlimits_{i=0}^n egin{Bmatrix}n\i end{Bmatrix}g(i)Longleftrightarrow g(n)=sumlimits_{i=0}^n(-1)^{n-i}egin {bmatrix} n\i end{bmatrix}f(i)
]
证明:
[largeegin{aligned}
f(n)&=sumlimits_{i=0}^n [n=i]f(i)\
&=sumlimits_{i=0}^nsumlimits_{j=i}^n (-1)^{i-j} egin {Bmatrix} n\j end{Bmatrix}egin {bmatrix} j\i end{bmatrix}f(i)\
&=sumlimits_{i=0}^n egin {Bmatrix} n\i end{Bmatrix}sumlimits_{j=0}^i (-1)^{i-j}egin {bmatrix} i\j end{bmatrix}f(j)\
&=sumlimits_{i=0}^n egin {Bmatrix} n\i end{Bmatrix}g(i)
end{aligned}
]
可以应用斯特林反演解释斯特林数与幂的关系:
[largeegin{aligned}
x^{overline{n}}=sum_{i=0}^negin{bmatrix}n\ iend{bmatrix}x^i &Longleftrightarrow x^n = sum_{i=0}^n (-1)^{n-i}egin{Bmatrix} n \i end{Bmatrix} x^{overline{i}} \
x^n = sumlimits_{i=0}^n egin{Bmatrix} n \i end{Bmatrix} x^{underline{i}} &Longleftrightarrow x^{underline{n}} = sumlimits_{i=0}^n(-1)^{n-i}egin{bmatrix}n\ iend{bmatrix}x^i \
end{aligned}
]
求法
第一类斯特林数·行
第 (n) 行第一类斯特林数的生成函数为:
[large x^{overline{n}}=sum_{i=0}^negin{bmatrix}n\ iend{bmatrix}x^i
]
设 (f(x)=x^{overline{n}}),考虑倍增,因为有 (x^{overline{2n}}=x^{overline{n}}(x+n)^{overline{n}}),所以求出 (f(x+n)) 后即可倍增,设 (a_i=[x^i]f(x)),得:
[largeegin{aligned}
f(x+n)&=sum_{i=0}^na_i(x+n)^i \
&=sum_{i=0}^na_isum_{j=0}^i inom{i}{j}x^jn^{i-j} \
&=sum_{i=0}^nx^isum_{j=i}^n inom{j}{i}a_jn^{j-i} \
&=sum_{i=0}^nfrac{x^i}{i!}sum_{j=i}^n j!a_jfrac{n^{j-i}}{(j-i)!} \
end{aligned}
]
卷积即可,复杂度为 (T(n)=T(frac{n}{2})+O(n log n)=O(n log n))。
第一类斯特林数·列
(n) 个元素构成 (1) 个轮换的 (EGF) 为:
[large sum_{i=1}^n (i-1)!frac{x^i}{i!}=lnfrac{1}{1-x}
]
得构成 (i) 个轮换的 (EGF) 为:
[large frac{(lnfrac{1}{1-x})^i}{i!}
]
多项式快速幂即可。
第二类斯特林数·行
因为有:
[large m^n = sumlimits_{i=0}^m inom{m}{i} egin{Bmatrix} n \i end{Bmatrix} i!
]
二项式反演得:
[largeegin{aligned}
egin{Bmatrix} n \m end{Bmatrix}&=frac{1}{m!}sum_{i=0}^m(-1)^{m-i}inom{m}{i}i^n \
&=sum_{i=0}^mfrac{(-1)^{m-i}}{(m-i)!}frac{i^n}{i!}
end{aligned}
]
卷积即可。
第二类斯特林数·列
(n) 个元素构成 (1) 个集合的 (EGF) 为:
[large sum_{i=1}^n frac{x^i}{i!}=e^x-1
]
得构成 (i) 个集合的 (EGF) 为:
[large frac{(e^x-1)^i}{i!}
]
多项式快速幂即可。