#P380. 练65.3 螺旋矩阵
练65.3 螺旋矩阵
Description
An spiral matrix can be generated as follows:
Start from the top-left corner (row , column ) and initially move to the right. If the next cell is unvisited, continue moving forward; otherwise, turn right. Repeat this process until all cells in the matrix have been visited. Fill the cells in the order they are visited with to form a spiral matrix.
The following is a spiral matrix for :
1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7
Input Format
A single line containing three integers , , , separated by spaces, representing the matrix size and the row and column of the number to be found. , , .
Output Format
Output a single integer, representing the number in the -th row and -th column of the matrix.
Sample
4 2 314