渐渐对深搜类的题有了自信, 虽然还只能做一些简单的题, 但是感觉还不错٩(‘ω’)و .
题目描述:由$1-n$这$n$个自然数组成一个环,要求任意相邻两数之和为素数, 按顺序输出这些数.
链接
原题
A ring is compose of $n$ circles as shown in diagram. Put natural number $1, 2,…,n$ into each circle separately, and the sum of numbers in two adjacent circles should be a prime.
Note: the number of first circle should always be 1.
题解
DFS遍历每一种情况.
代码
1 | /* |