2885. A spiral walk

单点时限: 3.0 sec

内存限制: 256 MB


Oh how the cows love to walk in their square pasture with sides of

length N (1 <= N <= 750) and which is partitioned into N*N squares.

They enjoy the sights, the smells, and the general ambience of the

grass and trees.

Bessie has decided to take the cows on the longest possible walk

from the upper left corner to the center (or near the center when

N is even) of the pasture, passing through each and every square

along the way after starting.

She has decided to create the obvious clockwise spiral route (example

below) for this evening's stroll. Write a program to create a map

for her that shows the order of squares she should visit.

By way of example, for pastures of size N=3 and N=4, here are the

routes Bessie should use:

1  2  3        1  2  3  4

8  9  4       12 13 14  5

7  6  5       11 16 15  6

10  9  8  7

输入格式


* Line 1: A single integer: N

输出格式


* Lines 1..N: N space-separated integers

样例

Input
3
Output
1 2 3
8 9 4
7 6 5

79 人解决,98 人已尝试。

94 份提交通过,共有 231 份提交。

3.3 EMB 奖励。

创建: 13 年,3 月前.

修改: 6 年,10 月前.

最后提交: 3 月,3 周前.

来源: N/A

题目标签