Let be a prime. We arrange the numbers in as a matrix . Next we can select any row or column and add to every number in it, or subtract from every number in it. We call the arrangement good if we can change every number of the matrix to in a finite number of such moves. How many good arrangements are there?
Solution
Let be a prime. We arrange the numbers in as a matrix . We can select any row or column and add 1 to every number in it, or subtract 1 from every number in it. We call the arrangement "good" if we can change every number of the matrix to 0 in a finite number of such moves. We aim to determine the number of good arrangements.
Assume we start with a good matrix and let and be the numbers of operations ("numbers add one" minus "numbers subtract one") on the -th row and -th column, respectively, to get a zero matrix. Then we should have:
Summing up all these equations, we obtain:
As a result, it implies the sum of numbers that lie on is constant for all .
By comparing these equations, we find that the first row of the matrix is just a translation of the second row, i.e., is constant for . This is true for any two other rows as well.
Thus, the problem boils down to finding and such that:
represents the -th row of matrix for , representing a partition of .
Without loss of generality, we can assume and . We try to prove that either (first column is ) or (first row is ).
If and , then neither the first row nor any other rows contain 2. We have two cases to consider:
1. :
This is straightforward. If , then there is no possible position for 3, so . Continuing in the same way, we find .
2. :
Let be the greatest number such that for all . Then where is ? Yes, and lie below . Playing around with possible positions, we arrive at the matrix:
This matrix implies , which is a contradiction since is prime.
Therefore, in both cases, we can suppose that . This argument works symmetrically for columns as well. Hence, the number of good arrangements is:
The answer is: