问题
So, I was constructing a matrix (square) of length N, its element i should between 1 <= i < 2 * N
- Each element should be between 1 to 2 * N - 1
- for each i and j (1 <= i <= N and 1 <= j < 2 * N) the j element should appear in ith row / i column
for any N
if the desired matrix is not possible we have print -1;
Which means for N = 2
We could get matrix as -
1 2
3 1
As we can see for 1st row and column we can get 1 , 2 , 3. and for 2nd row and column we get 1, 2, 3
Another example : for N = 4
1 2 4 6
3 1 6 5
5 7 1 3
7 4 2 1
please help.
来源:https://stackoverflow.com/questions/59630967/constructing-a-square-matrix-of-edge-n-and-its-element-should-not-be-same-acros