303674: CF710C. Magic Odd Square

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Magic Odd Square

题意翻译

请你构造一个 n × n 的矩阵,并且该矩阵是由 1 到 n2的数构成的,每个数只能使用一次,且这个矩阵的每行,每列,以及主对角线的和都为奇数。 Input 输入仅一行,保证矩阵的大小 n (1 ≤ n ≤ 49)为奇数。 Output 输出满足题意的矩阵,其中共有n 行, 并且每行有 n 个整数。

题目描述

Find an $ n×n $ matrix with different numbers from $ 1 $ to $ n^{2} $ , so the sum in each row, column and both main diagonals are odd.

输入输出格式

输入格式


The only line contains odd integer $ n $ ( $ 1<=n<=49 $ ).

输出格式


Print $ n $ lines with $ n $ integers. All the integers should be different and from $ 1 $ to $ n^{2} $ . The sum in each row, column and both main diagonals should be odd.

输入输出样例

输入样例 #1

1

输出样例 #1

1

输入样例 #2

3

输出样例 #2

2 1 4
3 5 7
6 9 8

Input

题意翻译

请你构造一个 n × n 的矩阵,并且该矩阵是由 1 到 n2的数构成的,每个数只能使用一次,且这个矩阵的每行,每列,以及主对角线的和都为奇数。 Input 输入仅一行,保证矩阵的大小 n (1 ≤ n ≤ 49)为奇数。 Output 输出满足题意的矩阵,其中共有n 行, 并且每行有 n 个整数。

加入题单

算法标签: