P27824 [洛谷] [Information and Future 2018] Prime Spiral Matrix
普及
题目描述

Problem Description

Fill a $n \times n$ matrix with the first $n^2$ prime numbers starting from the top-left corner, following the order of right, down, left, up, right, down, left, up, and so on, to form a spiral prime matrix. Below are examples of the spiral prime matrices for $n = 4$ and $n = 5$:

Given $n$, your task is to determine the value in the $x$-th row and $y$-th column of the $n \times n$ spiral prime matrix.

A prime number, also known as a prime, is a positive integer greater than 1 that has no divisors other than 1 and itself.

Input Format

Input consists of three positive integers $n, x, y$.

Output Format

Output a single integer, which is the value in the $x$-th row and $y$-th column of the $n \times n$ spiral prime matrix.

Sample Input and Output

Sample Input #1

5 1 4

Sample Output #1

7

Sample Input #2

5 4 3

Sample Output #2

79

Notes

Sample Explanation

Refer to the diagram for $n = 5$.

Data Size

All data satisfies $1 \leq x, y \leq n \leq 20$.

This problem originally had a full score of $15\text{pts}$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 4
样例输出
7