#P380. 练65.3  螺旋矩阵

练65.3  螺旋矩阵

Description

An n×nn \times n spiral matrix can be generated as follows:
Start from the top-left corner (row 11, column 11) 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 1,2,3,,n21, 2, 3, \ldots, n^2 to form a spiral matrix.
The following is a spiral matrix for n=4n=4:

 1  2  3  4
12 13 14  5
11 16 15  6
10  9  8  7

Input Format

A single line containing three integers nn, ii, jj, separated by spaces, representing the matrix size and the row and column of the number to be found. 1n30,0001\leq n\leq 30,000, 1in1\leq i\leq n, 1jn1\leq j\leq n.

Output Format

Output a single integer, representing the number in the ii-th row and jj-th column of the matrix.

Sample

4 2 3
14