6757. 2020.07.21【NOI2020】模拟T3

题意

一个长度为 n n n的序列 h i h_i hi,每个数的取值范围为 [ 1 , m ] [1,m] [1,m]
求恰好有 k k k h i < h i + 1 h_ihi<hi+1的序列个数。
题目保证 n − k + 1 n-k+1 nk+1不会很大。
n ≤ 2 20 − 10 n\le 2^{20}-10 n22010
( n − k + 1 ) m ≤ 2 20 − 10 (n-k+1)m\le 2^{20}-10 (nk+1)m22010

正解

恰好 k k k次升调比较难算,所以二项式反演,转化成至少 k k k次升调。

k k k次升调相当于 n − 1 − k n-1-k n1k次非升调,所以有 n − k n-k nk段,每段都是升调。

设一段全是升调的生成函数为 F ( x ) F(x) F(x)。显然 F ( x ) = ∑ k ≥ 1 ( m k ) x k = ( 1 + x ) m − 1 F(x)=\sum_{k\ge 1} \binom{m}{k}x^k=(1+x)^m-1 F(x)=k1(km)xk=(1+x)m1

n − k n-k nk段,所以答案为 [ x n ] F n − k ( x ) [x^n]F^{n-k}(x) [xn]Fnk(x)。为了后面计算方便记 f ( x ) = F ( x ) x f(x)=\frac{F(x)}{x} f(x)=xF(x),于是答案为 [ x k ] f n − k ( x ) [x^k]f^{n-k}(x) [xk]fnk(x)

把总答案的式子给写出来:

A N S = ∑ n = k + 1 N ∑ i ≥ k f n − i ( x ) [ x i ] ( i k ) ( − 1 ) i − k ANS=\sum_{n=k+1}^N\sum_{i\ge k} f^{n-i}(x)[x^i]\binom{i}{k}(-1)^{i-k} ANS=n=k+1Nikfni(x)[xi](ki)(1)ik

= ∑ i = k N 1 − f N − i + 1 ( x ) 1 − f ( x ) [ x i ] ( i k ) ( − 1 ) i − k =\sum_{i=k}^N\frac{1-f^{N-i+1}(x)}{1-f(x)}[x^i]\binom{i}{k}(-1)^{i-k} =i=kN1f(x)1fNi+1(x)[xi](ki)(1)ik

(这里已经假设了 k > 0 k>0 k>0,忽略了零次项)

= ∑ i = k N x N − i + 1 − F N − i + 1 ( x ) 1 − f ( x ) [ x N + 1 ] ( i k ) ( − 1 ) i − k =\sum_{i=k}^N\frac{x^{N-i+1}-F^{N-i+1}(x)}{1-f(x)}[x^{N+1}]\binom{i}{k}(-1)^{i-k} =i=kN1f(x)xNi+1FNi+1(x)[xN+1](ki)(1)ik

= [ x N + 1 ] 1 1 − f ( x ) ∑ i = k N ( i k ) ( − 1 ) i − k ( x N − i + 1 − F N − i + 1 ( x ) ) =[x^{N+1}]\frac{1}{1-f(x)}\sum_{i=k}^N\binom{i}{k}(-1)^{i-k}(x^{N-i+1}-F^{N-i+1}(x)) =[xN+1]1f(x)1i=kN(ki)(1)ik(xNi+1FNi+1(x))

现在主要问题变成了求 ∑ i = k N ( i k ) ( − 1 ) i − k F N − i + 1 ( x ) \sum_{i=k}^N \binom{i}{k}(-1)^{i-k}F^{N-i+1}(x) i=kN(ki)(1)ikFNi+1(x)

i = N + 1 i=N+1 i=N+1时显然没有 x N + 1 x^{N+1} xN+1项,所以放宽对 i i i的限制。

= ∑ i = k N + 1 ( i k ) ( − 1 ) i − k F N − i + 1 ( x ) =\sum_{i=k}^{N+1} \binom{i}{k}(-1)^{i-k}F^{N-i+1}(x) =i=kN+1(ki)(1)ikFNi+1(x)

= ∑ i = k N + 1 ( i k ) ( − 1 ) i − k ( ( 1 + x ) m − 1 ) N − i + 1 =\sum_{i=k}^{N+1} \binom{i}{k}(-1)^{i-k}((1+x)^m-1)^{N-i+1} =i=kN+1(ki)(1)ik((1+x)m1)Ni+1

暴力拆开,推若干步得:

= ∑ j = 0 N − k + 1 ( 1 + x ) m j ∑ i = k N − j + 1 ( i k ) ( N − i + 1 j ) ( − 1 ) N + k + 1 + j =\sum_{j=0}^{N-k+1}(1+x)^{mj}\sum_{i=k}^{N-j+1}\binom{i}{k}\binom{N-i+1}{j}(-1)^{N+k+1+j} =j=0Nk+1(1+x)mji=kNj+1(ki)(jNi+1)(1)N+k+1+j

= ∑ j = 0 N − k + 1 ( 1 + x ) m j ( N + 2 j + k + 1 ) ( − 1 ) N + k + 1 + j =\sum_{j=0}^{N-k+1}(1+x)^{mj}\binom{N+2}{j+k+1}(-1)^{N+k+1+j} =j=0Nk+1(1+x)mj(j+k+1N+2)(1)N+k+1+j

(组合意义:一个长度为 N + 2 N+2 N+2的表格,选 j + k + 1 j+k+1 j+k+1个格子;枚举第 k + 1 k+1 k+1个格子的位置(已经钦定是第几个,方案唯一),左边选 k k k右边选 j j j

= ∑ i = 0 m ( N − k + 1 ) x i ∑ j = 0 N − k + 1 ( m j i ) ( N + 2 j + k + 1 ) ( − 1 ) N + k + 1 + j =\sum_{i=0}^{m(N-k+1)}x^i\sum_{j=0}^{N-k+1}\binom{mj}{i}\binom{N+2}{j+k+1}(-1)^{N+k+1+j} =i=0m(Nk+1)xij=0Nk+1(imj)(j+k+1N+2)(1)N+k+1+j

这个东西可以用卷积算。

你可能感兴趣的:(数学)