考虑和式 ∑ i = 0 n − 1 ( ∑ j = 0 i ( n j ) ) 3 \sum_{i=0}^{n-1} \left(\sum_{j=0}^i \binom n j\right)^3 ∑i=0n−1(∑j=0i(jn))3 的结果。
设答案为 S S S,我们考虑另一个和式:
∑ i , j , k ( n i ) ( n j ) ( n k ) ⋅ ( max { i , j , k } − min { i , j , k } ) \sum_{i,j,k}\binom n i \binom n j \binom n k \cdot \left( \max\{i,j,k\} - \min\{i,j,k\} \right) i,j,k∑(in)(jn)(kn)⋅(max{i,j,k}−min{i,j,k})
它有一种算法,就是枚举每个间隔,假设 [ i , i + 1 ] [i,i+1] [i,i+1] 这个间隔在 max − min \max - \min max−min 内,有 2 3 n − ( ∑ j = 0 i ( n j ) ) 3 − ( ∑ j = 0 n − i − 1 ( n j ) ) 3 2^{3n} - \left(\sum_{j=0}^i \binom n j\right)^3 - \left(\sum_{j=0}^{n-i-1} \binom n j\right)^3 23n−(∑j=0i(jn))3−(∑j=0n−i−1(jn))3 种方案,这是容斥掉在它两边的情况得到的。对 i i i 求和,得到的就是 n 2 3 n − 2 S n2^{3n} - 2S n23n−2S。
另一种算法,是考虑到一个优秀的性质: 2 ( max { i , j , k } − min { i , j , k } ) = ∣ i − j ∣ + ∣ j − k ∣ + ∣ k − i ∣ 2(\max\{i,j,k\} - \min\{i,j,k\}) = |i - j| + |j - k| + |k - i| 2(max{i,j,k}−min{i,j,k})=∣i−j∣+∣j−k∣+∣k−i∣。
这样一来,和式就被变成了只和两个变量独立的情况。也就是
∑ i , j , k ( n i ) ( n j ) ( n k ) ⋅ ( max { i , j , k } − min { i , j , k } ) = 3 2 ⋅ 2 n ∑ i , j ( n i ) ( n j ) ∣ i − j ∣ \sum_{i,j,k}\binom n i \binom n j \binom n k \cdot \left( \max\{i,j,k\} - \min\{i,j,k\} \right) = \frac 3 2 \cdot 2^n \sum_{i,j} \binom n i \binom n j |i - j| i,j,k∑(in)(jn)(kn)⋅(max{i,j,k}−min{i,j,k})=23⋅2ni,j∑(in)(jn)∣i−j∣
后者的推导并不困难:
∑ i , j ( n i ) ( n j ) ∣ i − j ∣ = 2 ∑ i ≥ j ( n i ) ( n j ) ( i − j ) = 2 n ∑ i ≥ j [ ( n − 1 i − 1 ) ( n j ) − ( n i ) ( n − 1 j − 1 ) ] = 2 n ∑ d ≥ 0 ∑ d = i − j [ ( n − 1 j + d − 1 ) ( n n − j ) − ( n j + d ) ( n − 1 n − j ) ] = 2 n ∑ d ≥ 0 [ ( 2 n − 1 n + d − 1 ) − ( 2 n − 1 n + d ) ] = 2 n ( 2 n − 1 n − 1 ) = n ( 2 n n ) \begin{aligned} & \quad \sum_{i,j} \binom n i \binom n j |i - j| \\ & = 2\sum_{i\ge j} \binom n i \binom n j (i - j) \\ & = 2n\sum_{i\ge j} \left[ \binom {n-1}{i - 1} \binom n j - \binom n i \binom{n - 1}{j - 1} \right]\\ & = 2n\sum_{d \ge 0} \sum_{d = i - j} \left[ \binom {n-1}{j + d - 1} \binom n {n - j} - \binom n {j + d} \binom{n - 1}{n - j} \right]\\ & = 2n\sum_{d \ge 0} \left[ \binom {2n-1}{n + d - 1} - \binom{2n - 1}{n + d} \right]\\ & = 2n \binom{2n-1}{n-1} = n\binom{2n}{n} \end{aligned} i,j∑(in)(jn)∣i−j∣=2i≥j∑(in)(jn)(i−j)=2ni≥j∑[(i−1n−1)(jn)−(in)(j−1n−1)]=2nd≥0∑d=i−j∑[(j+d−1n−1)(n−jn)−(j+dn)(n−jn−1)]=2nd≥0∑[(n+d−12n−1)−(n+d2n−1)]=2n(n−12n−1)=n(n2n)
联立两式,我们就有
3 2 ⋅ 2 n ⋅ n ( 2 n n ) = n 2 3 n − 2 S S = n 2 3 n − 1 − 3 n ⋅ 2 n − 2 ( 2 n n ) \begin{aligned} \frac 3 2 \cdot 2^n \cdot n \binom {2n}n &= n2^{3n} - 2S\\ S &= n 2^{3n - 1} - 3n \cdot 2^{n-2} \binom{2n}{n} \end{aligned} 23⋅2n⋅n(n2n)S=n23n−2S=n23n−1−3n⋅2n−2(n2n)