摘要:
题目链接题目大意:给你一个数n,让你找到从1到n的序列,使相邻的两项相加的和是素数(包括第一个数和最后一个数的和)。经典的DFS题!dfs(int k,int now) //k表示递归的深度,now表示已生成序列的末尾数。贴代码了: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 5 using namespace std; 6 7 int ans[25]; 8 int f[25]; 9 int n;10 11 int isprime(int x)12 {13 for(int 阅读全文
posted @ 2012-09-19 18:40
Amazing_Y
阅读(1175)
评论(0)
推荐(0)