返回题库

网格填充

Grid Fill

专题
Brainteaser / 脑筋急转弯
难度
L2

题目详情

你将获得一个 3×33 \times 3 网格,上面放置数字 1 到 9。每个数字只能使用一次,每个网格单元只有一个数字。你可以用多少种方法来放置数字,以使每一行和每一列的总和都是偶数?

You are given a 3×33 \times 3 grid upon which the numbers 1 through 9 are placed. Each number can only be used once and each grid cell only has one number. How many ways can you place the numbers so that the sum of every row and column is even?

解析

以这种方式放置数字是不可能的。由于我们仅限于使用号码 1...91...9,因此我们总共有 5 个奇数和 4 个偶数可供选择。为了使行/列之和为偶数,我们必须有 1 个偶数和 2 个奇数,或者只有 3 个偶数(例如:1 + 2 + 3 = 6 和 2 + 4 + 6 = 12)。这也意味着我们不能有任何只由两个偶数组成的行或列​​。

由于网格有 3 列,并且我们无法将两个偶数分配给一列,因此必须有一列有 3 个偶数,一列有 1 个偶数,一列有 0 个偶数。然而,通过在一列中放置三个偶数,我们最终将得到至少一行恰好有两个偶数(尝试通过绘制网格来可视化这一点!)。

这违反了我们在该解决方案的第一部分中讨论的规则,因此我们可以得出结论,没有可能的方法来填充该网格以使所有行和所有列都是偶数。


Original Explanation

It is impossible to place the numbers in such a manner. Since we are restricted to using the numbers 1...91...9, we have a total of 5 odd numbers and 4 even numbers to choose from. In order for a row/column to sum to an even number we must have 1 even and 2 odds or just 3 evens (Ex: 1 + 2 + 3 = 6 and 2 + 4 + 6 = 12). This also means that we can't have any rows or columns that only consist of two even numbers.

Since the grid has 3 columns and we can't assign two even numbers to one column, there will have to be one column that has 3 evens, one column that has 1 even, and one column that has 0 evens. However, by placing three even numbers in a column, we will end up having at least one row that has exactly two even numbers (try visualizing this by drawing a grid!).

This violates the rule we discussed in the first part of this solution and therefore we can conclude that there are no possible ways to fill this grid so that all the rows and all the columns are even.