Problem

Source: Macedonia National Olympiad 2016

Tags: combinatorics



A magic square is a square with side 3 consisting of 9 unit squares, such that the numbers written in the unit squares (one number in each square) satisfy the following property: the sum of the numbers in each row is equal to the sum of the numbers in each column and is equal to the sum of all the numbers written in any of the two diagonals. A rectangle with sides $m\ge3$ and $n\ge3$ consists of $mn$ unit squares. If in each of those unit squares exactly one number is written, such that any square with side $3$ is a magic square, then find the number of most different numbers that can be written in that rectangle.