Prime Ring ProblemProblem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circl...
分类:
其他好文 时间:
2015-07-31 20:10:45
阅读次数:
186
DescriptionA ring is composed of n (even number) circles as shown in diagram. Put natural numbersinto each circle separately, and the sum of numbers i...
分类:
其他好文 时间:
2015-07-30 22:55:30
阅读次数:
143
1 #include 2 #include 3 using namespace std; 4 5 int n, A[50], isp[50], vis[50]; 6 7 int is(int x) 8 { 9 for(int i = 2; i*i n (0 2 #include...
分类:
其他好文 时间:
2015-07-30 18:36:13
阅读次数:
475
Description
A ring is composed of n (even number) circles as shown in diagram. Put natural numbers
into each circle separately, and the sum of numbers in two adjacent circles should be a prim...
分类:
其他好文 时间:
2015-07-27 21:00:32
阅读次数:
125
《计算机算法设计与分析》(第3版) 王晓东 电子工业出版社递归与分治策略二分搜索算法二路归并排序快速排序动态规划矩阵连乘问题斐波那契数列贪心算法最优装载活动安排问题其它可用贪心算法求解的问题回溯法图的m着色问题素数环问题分支限界法装载问题
分类:
编程语言 时间:
2015-07-12 21:31:26
阅读次数:
183
一. 问题描述把从1到n(n>=2)这n个数摆成一个环,要求相邻的两个数的和是一个素数,找出所有满足条件的环。二. 问题分析1> 解向量:2> 解空间树:排列树,(n-1)!个叶子结点3> 剪枝函数:isPrime( x[t-1]+x[t] ),t=2,3,···,n 约束函数三. 算法实现#inc...
分类:
其他好文 时间:
2015-07-11 12:07:42
阅读次数:
127
素数环时间限制:1000ms | 内存限制:65535KB难度:2描述有一个整数n,把从1到n的数字无重复的排列成环,且使每相邻两个数(包括首尾)的和都为素数,称为素数环。为了简便起见,我们规定每个素数环都从1开始。例如,下图就是6的一个素数环。输入有多组测试数据,每组输入一个n(0#include...
分类:
其他好文 时间:
2015-06-05 12:02:15
阅读次数:
102
http://acm.hdu.edu.cn/showproblem.php?pid=1016这道题是经典的素数环问题,相邻的两个数之和是素数。解题方法:用的是深搜,以1为起点,搜索,下一个数为出去前面的数字的集合。(用vis数组记录访问过的节点)剪枝:当前搜索值与数组前一个值之和不为素数的时候返回。...
分类:
其他好文 时间:
2015-05-23 06:23:53
阅读次数:
155
1 #include 2 #include 3 #define MAX 12 4 int used[21]={0},resl[21]={0},zs[50]={0};//used=已使用 resl=结果 zs=质数 5 int total=0; 6 void output() 7 { 8 ...
分类:
其他好文 时间:
2015-05-16 20:10:30
阅读次数:
147
题目描述Description从1到20这20个数摆成一个环,要求相邻的两个数的和是一个素数。输入输出格式Input/output输入格式:无输入输出格式:一个整数(第几号素数环),一列数字(表示这个素数环)输入输出样例Sample input/output样例测试点#1输入样例:无输出样例:这里就...
分类:
其他好文 时间:
2015-05-03 17:26:00
阅读次数:
120