返回题库

二维网格博弈 II

2D Grid Game II

专题
Discrete Math / 离散数学
难度
L4

题目详情

你正在玩一款 2D 游戏,你的角色被困在 6 × 6 网格中。你的角色从 (1, 1) 开始,只能向下和向右移动。有两个道具位于 (2, 3) 和 (4, 6)。你的角色可以采取多少种可能的路径到达 (6 ,6),以便它收集至少一项能量提升?

You are playing a 2D game where your character is trapped in a 6 × 6 grid. Your character starts at (1, 1), and can only move down and right. There are two power-ups located at (2, 3) and (4, 6). How many possible paths can your character take to get to (6 ,6), such that it collects at least one power-up?

解析

该问题是 2D Grid Game 的扩展,答案解释假设你理解该问题。

在这个问题中,我们可以将所有的路数分成两部分。一种方法是我们在 (2, 3) 处“击中”第一个加电,另一种方法是我们在 (4, 6) 处“击中”第二次加电。然后我们计算从 (1, 1) 到 (2, 3),然后从 (2, 3) 到 (6, 6) 的方式数量。我们将这两个值相乘,得到从 (1, 1) 到 (6, 6) 到 (2, 3) 的路径总数。我们重复相同的过程,但对于 (4, 6)。现在我们有两个值,每个值对应于通过两个通电之一到达 (6, 6) 的方式数量。

然而,需要注意的是,这两个事件(通过 (2, 3) 和通过 (4, 6))并不相互排斥。它们都可以出现在有效的解决方案中。因此,在计算这两个计数时,我们多算了从 (1, 1) 到 (6, 6) 并经过 (2, 3) 和 (4, 6) 的路径数量。这是因为这条假设路径包含在我们的两个计数中。因此,以这种方式计数并从上面的两个计数中减去它就可以得出我们准确的路线数。

使用上述逻辑,我们可以计算出解决方案: (31)(73)+(83)(22)(31)(53)(22)\begin{equation*} {3 \choose 1} {7 \choose 3} + {8 \choose 3} {2 \choose 2} - {3 \choose 1} {5 \choose 3} {2 \choose 2} \end{equation*} 给我们131131总路径的最终答案。


Original Explanation

This question is an extension of 2D Grid Game and the answer explanation assumes understanding of that question.

In this problem, we can partition the total number of ways into two. One method where we ‘hit’ the first powerup at (2, 3), and another method where we ‘hit’ the second powerup at (4, 6). We then count the number of ways to get from (1, 1) to (2, 3), then from (2, 3) to (6, 6). We multiply these two values together to get the total number of ways from (1, 1) to (6, 6) through (2, 3). We repeat the same process, but for (4, 6). We now have two values each corresponding to the number of ways to (6, 6) through one of the two powerups.

However, it’s important to note the two events (passing through (2, 3) and passing through (4, 6)) are not mutually exclusive. They can both occur in a valid solution. Therefore, in the calculation of each of these two counts, we overcounted the number of ways to get from (1, 1) to (6, 6) passing through both (2, 3) and (4, 6). This is because this hypothetical path is included in both our two counts. Therefore, counting this way and subtracting it from the two counts above would yield our accurate number of ways.

Using the above logic, we can calculate the solution as:

(31)(73)+(83)(22)(31)(53)(22)\begin{equation*} {3 \choose 1} {7 \choose 3} + {8 \choose 3} {2 \choose 2} - {3 \choose 1} {5 \choose 3} {2 \choose 2} \end{equation*}

Giving us a final answer of 131131 total paths.