Submit | All submissions | Best solutions | Back to list |
HS12SPRL - Anti Ulam Spirals |
You might be aware of the Ulam spiral. Your task in this problem is to print a finite Ulam-like spiral of integers but starting with 1 at the upper left corner (please consult the example below).
Input
You are given one integer t, denoting the number of testcases (t <= 100). In each of the following t lines one positive integer n ( n <= 200) - the requested size of the spiral.
Output
For each of the test cases output the requested spiral. Separate succesive cases by an empty line.
Example
Input: 4 2 4 1 5 Output: 1 2 4 3 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 1 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Scoring
By solving this problem you score 10 points.
Added by: | kuszi |
Date: | 2012-10-24 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP C++ 4.3.2 CPP C99 CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO HASK ICON ICK JAVA JS-RHINO LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PERL6 PHP PIKE PRLG-swi PYTHON PYTHON3 RUBY SCALA SCM guile SCM qobi ST TCL WHITESPACE |
Resource: | High School Programming League |