Prosječni
의견: 0
1 \(s / 64\) \(MB / 120\) points
Slavko is bored, so he’s filling out an N
N table with positive integers.
×
He’s particularly happy if he manages to fill out the table so that the following conditions are
met:
●
The average of the numbers in each row is an integer that is located in the same row.
●
The average of the numbers in each column is an integer that is located in the same
column.
●
All numbers in the table are different.
Help Slavko find a table that will make him happy.
The first line of input contains the integer N (\(1 \le N \le 100\)).
Output N lines, in each line output N integers separated by space.
Let the j ^{th} number in the i ^{th} line correspond to the value that Slavko will write down in the i ^{th}
row and j {th}{ } column of the table.
All numbers must be greater than 0 and smaller than 1 000 000 000.
If there are multiple solutions, output any.
If there is no solution, outp\(ut -1\).
3
2output
1 2 3
4 5 6
7 8 9
-1Clarification of the first test case:
The averages of individual rows are, respectively: 2, 5, 8.
The averages of individual columns are, respectively: 4, 5, 6.
Since the average of each row is located in the correspoding row and the average of each column is
located in the corresponding column, the output table will make Slavko happy.
평가 및 의견
Prosječni
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Prosječni