Editorial for COCI '16 Contest 2 #4 Prosječni


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

The task can be solved in a lot of different ways.

One of the possible solutions is the following:

  • In the first row, we write down the numbers 1, 2, \dots, n-1, \frac{n(n-1)}{2}.
  • Each following row but the last is obtained by adding \frac{n(n-1)}{2} to each number from the previous row.
  • The last row is obtained in the following way: For each column, if the numbers a_1, a_2, \dots, a_{n-1} are the numbers written in that column so far, we write the number n \times a_{n-1} - (a_1 + a_2 + \dots + a_{n-1}) in the n^\text{th} row in that column. By doing this, we achieved that the average of that column is equal to the next to last number in the column.

The only thing left is to make sure that the average of the last row is in that row. We leave this as an exercise for the reader to prove that the average is equal to the number in the last row and the next to last column.


Comments

There are no comments at the moment.