Filling the matrix in a spiral
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Create a program that populates a table with numbers ranging from 1 to M·N, beginning at the top-left corner and spiraling inward in a clockwise direction (refer to the example for clarity).
Input
The first line contains the natural numbers N and M, which represent the dimensions of the table (1 ≤ N, M ≤ 50).
Output
Output a table filled with numbers in the specified spiral order.
Examples
Input #1
Answer #1
Submissions 143
Acceptance rate 39%