Messy Matrix
Time Limit: 10 Seconds Memory Limit: 32768 KB
Special Judge
So, instead of solving this problem, Polivic comes up with another method to
entertain Grace. He turns over all the chips, and set a positive number (start
from 1,continuously) for each chip. Then he arranges these chips again, and
compute sums of every row, every column, and two diagonals. Polivic wants Grace
to see it's really magic, because there are many many different sums.
Now, Polivic wants you to help him to find such a matrix that the number of
different sums are maximized.
Notice
1. The original picture will be cut N times horizontally and N times vertically.
2. All chips are of the same size.
3. We will set the numbers ranged from 1 to N*N.
4. There will be 2*N+2 sums.
5. If there are multiplicate solutions, output any of them.
Input
Each line contains an integer N (1 <= N <= 100).
Output
For each case, output a matrix (N by N).
Print a blank line after each case.
Sample Input
1 2
Sample Output
1 1 3 2 4Submit
Source: ZOJ Monthly, January 2003