#P6497. [COCI 2016/2017 #2] Prosječni
[COCI 2016/2017 #2] Prosječni
Description
Slavko wants to fill an matrix with distinct positive integers such that:
- The average of the numbers in each row is an integer that appears in that row.
- The average of the numbers in each column is an integer that appears in that column.
- For any element in the matrix, .
Please help him find any feasible solution.
Input Format
One line with one integer .
Output Format
This problem uses Special Judge.
If there is no solution, output -1.
Otherwise, output lines, each containing integers, representing any matrix that meets the requirements.
3
1 2 3
4 5 6
7 8 9
2
-1
Hint
Sample 1 Explanation
The row averages are , and each is an integer in its corresponding row.
The column averages are , and each is an integer in its corresponding column.
Constraints
For of the testdata, .
Notes
Translated from COCI2016-2017 CONTEST #2 T4 Prosječni。
Translated by ChatGPT 5
京公网安备 11011102002149号