#B3738. Snake Prime Matrix
Snake Prime Matrix
Snake Prime Matrix
Given a positive integer n, generate an n \(\times\) n snake prime matrix by filling the first \(n^2\) prime numbers (a prime number is a positive integer greater than 1 that has no divisors other than 1 and itself) in a spiral order. The spiral order is defined as: right, down, left, up, and then repeating this cycle, starting from the top-left corner.
You are also given two integers r and c which represent the row and column indices (1-indexed) of a cell in the matrix. Your task is to output the prime number located at that cell.
inputFormat
The input consists of a single line containing three integers: \(n\) (the size of the matrix), \(r\) (the row index), and \(c\) (the column index), where 1 ≤ r, c ≤ n.
outputFormat
Output the prime number located at the \(r\)-th row and \(c\)-th column of the snake prime matrix.
sample
4 1 1
2