G - Teleporting Takahashi Editorial by LHF


English Editorial:

Without loss of generality, we can only consider the case \(x,y,z\ge 0\).

First, let’s solve the case that the answer is \(0\).

If \(x+y+z>n\) or \((n-x-y-z)\bmod 2=1\), than the answer is \(0\).

Consider the other case in a two-dimensional plane.

Let \(F[k]\) denote a scheme that takes \(x+y+2k\) steps from \((0,0)\) to \((x,y)\).

We have

\[ \begin{aligned} F[k]&=\sum_{i=0}^k\binom {x+y+2k}{x+i\;\;i\;\;y+k-i\;\;k-i}\\ &=\sum_{i=0}^k\binom{x+y+2k}{x+y+k}\binom{x+y+k}{y+k-i}\binom{k}{i}\\ &=\binom{x+y+2k}{x+y+k}\sum_{i=0}^k\binom{x+y+k}{y+k-i}\binom{k}{i}\\ &=\binom{x+y+2k}{x+y+k}\binom{x+y+2k}{y+k} \end{aligned} \]

The last step is equivalent to the number of solutions that have \(x+y+2k\) balls and put them into \(y+k\) boxes. Specifically, we can enumerate how many balls are placed in the last \(k\) box.

And we can insert the third dimension, we can use insertion method to solve it.

中文题解:

不失一般性的,我们假设 \(x,y,z\ge 0\)

我们先判掉答案为 \(0\) 的情况,如果 \(x+y+z\ge n\) 或者 \((n-x-y-z)\bmod 2=1\),则答案为 \(0\)

我们先考虑二维的情况,设 \(F[k]\) 表示走 \(x+y+2k\) 步从 \((0,0)\)\((x,y)\) 的方案数。

我们有:

\[ \begin{aligned} F[k]&=\sum_{i=0}^k\binom {x+y+2k}{x+i\;\;i\;\;y+k-i\;\;k-i}\\ &=\sum_{i=0}^k\binom{x+y+2k}{x+y+k}\binom{x+y+k}{y+k-i}\binom{k}{i}\\ &=\binom{x+y+2k}{x+y+k}\sum_{i=0}^k\binom{x+y+k}{y+k-i}\binom{k}{i}\\ &=\binom{x+y+2k}{x+y+k}\binom{x+y+2k}{y+k} \end{aligned} \]

其中最后一步转化可以这样理解:我们有 \(x+y+2k\) 个球,我们要从中选出 \(y+k\) 个球,那么我们可以枚举最后 \(k\) 个球中选了多少个,也就是第二步后面的那一坨式子。

其实这就是经典的范德蒙德卷积。

然后对于第三维,可以使用插入法解决,十分简单,不再赘述。

posted:
last update: