#P5512. [NOIP 1997 提高组] 棋盘问题 加强版
[NOIP 1997 提高组] 棋盘问题 加强版
Description
On an chessboard (), fill in numbers , such that the sum of any two adjacent numbers is a prime number.
For example, when , one solution is:
The adjacent pairs whose sums are prime are:
When , one possible filling is:
Here we require that the top-left cell must contain the number .
Input Format
One line with an integer .
Output Format
If there are multiple solutions, output the arrangement with the smallest sum of the first row and the first column. If there is no solution, output NO.
2
1 2
4 3
1
NO
Hint
For , each has one test point. For some reasons, is not necessarily the same as the test point ID.
The testdata was newly fixed on 2020.1.20.
Translated by ChatGPT 5
京公网安备 11011102002149号