Each square of an n × n grid is coloured either blue or red, where n is a positive integer. There are k blue cells in the grid. Pat adds the sum of the squares of the numbers of blue cells in each row to the sum of the squares of the numbers of blue cells in each column to form . He then performs the same calculation on the red cells to compute .
If , determine (with proof) all possible values of .
Solution
If the -th row of the grid has blue cells, then the contribution to
from this row is . Adding these contributions over
all rows yields and similarly the columns also contribute ;
thus we have
Next, denote the number of red cells by , and suppose that there are more
blue cells than red cells. Then and , which implies .
When we add these two equations we obtain , hence
and
Since we are given that , this implies that and so
or . Note that is not possible as
. Using , in the first case, we get and in the second
case, .
The equation shows that only depends on
the size of the grid and the number of blue cells, but not on the position
of the blue cells. Therefore, making any 15 of the 25 cells of a 5 × 5 grid
blue gives a colouring which satisfy the conditions of the problem for .
Also, making any 313 of the 625 cells of a 25 × 25 grid blue gives a colouring
which satisfy the conditions of the problem for .