MathLabs

Problem 2

Find all integers nn for which each cell of an n×nn\times n table can be filled with one of the letters II, MM, and OO in such a way that: in each row and each column, one third of the entries are II, one third are MM, and one third are OO; and in any diagonal, if the number of entries on the diagonal is a multiple of three, then one third of the entries on that diagonal are II, one third are MM, and one third are OO. (Note that an n×nn\times n table has 4n−24n-2 diagonals in total, in both directions.)
Step 5 of 5: Conclude 9∣n9\mid n
In plain words

The global count of II agrees with the two-way count only when n2/9n^2/9 is divisible by 33.

13n2=49n2−3a⇒9∣n\tfrac13n^2=\tfrac49n^2-3a\quad\Rightarrow\quad 9\mid n
Detailed analysis

The row condition gives exactly n2/3n^2/3 cells containing II. Equating this with the count from Steps 3 and 4 gives n2/3=4n2/9−3an^2/3=4n^2/9-3a, hence 3a=n2/93a=n^2/9. Thus 3∣n2/93\mid n^2/9, and since 3∣n3\mid n, this is equivalent to 9∣n9\mid n. Together with the explicit periodic tile, the answer is exactly the positive multiples of 99.