eolymp
bolt
Try our new interface for solving problems
Problems

Print the chessboard

Print the chessboard

You are given a chessboard of size $n \times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $ceil(n^2 / 2)$ numbers from $1$ to $ceil(n^2 / 2)$ are written in the cells with an even sum of coordinates from left to right from top to bottom. The rest of the $n^2 - ceil(n^2 / 2)$ numbers from $ceil(n^2 / 2) + 1$ to $n^2$ are written in the cells with an odd sum of coordinates from left to right from top to bottom. The operation $ceil(x / y)$ means division $x$ by $y$ rounded up. \InputFile One integer $n~(1 \le n \le 9)$. \OutputFile Print the matrix --- the chessboard in the given manner. Watch for alignment!
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
Output example #1
 1 14  2 15  3 
16  4 17  5 18 
 6 19  7 20  8 
21  9 22 10 23 
11 24 12 25 13 
Input example #2
6
Output example #2
 1 19  2 20  3 21 
22  4 23  5 24  6 
 7 25  8 26  9 27 
28 10 29 11 30 12 
13 31 14 32 15 33 
34 16 35 17 36 18