登录
首页 » 算法 » 素数环: 把从1到10这10个数摆成一个环,要求相邻的两个数的和是一个素数。 〖问题分析〗 这是一道回溯的题目。从1开始,每个空位有9种可能,每种可能加入约束...

素数环: 把从1到10这10个数摆成一个环,要求相邻的两个数的和是一个素数。 〖问题分析〗 这是一道回溯的题目。从1开始,每个空位有9种可能,每种可能加入约束...

于 2022-03-13 发布 文件大小:54.02 kB
0 119
下载积分: 2 下载次数: 1

代码说明:

素数环: 把从1到10这10个数摆成一个环,要求相邻的两个数的和是一个素数。 〖问题分析〗 这是一道回溯的题目。从1开始,每个空位有9种可能,每种可能加入约束条件即可 1.与前面所有的数不重复 2.与前一个数和为素数(最后一个和第一个也要满足)。 〖算法流程〗 1、数据初始化; 2、递归填数: 判断第J种可能是否合法; A、如果合法:填数;判断是否到达目标(10个已填完): 是,打印结果;不是,递归填下一个; B、如果不合法:选择下一种可能;-Prime Central: 1-10 from 10 the number of put this into a ring, asked the two adjacent numbers and is a prime number. 〗 〖Analysis is a retrospective this topic. From 1 year, 9 out of every space possible, each may be bound by the conditions of accession to 1. And in front of all the number of non-repetition, 2. With a few and for a prime number (the last and the first to meet). 1〗 〖algorithm processes the data to initialize 2, fill in the number of recursion: first to determine the legality of J possible A, if the legitimate: the number of Reclamation to determine whether the target (10 have been completed): Yes, print the results of not, fill in the next recursive B, if not legitimate: a possible alternative

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论


0 个回复

  • The lingo of learning courseware, very good thing to use.
    有关lingo的学习课件,很好用的东西。-The lingo of learning courseware, very good thing to use.
    2023-01-29 17:25:04下载
    积分:1
  • 距阵链乘问题: 找出矩阵链乘A(35*40) A(40*20) A(20*10) A(10*15)的最佳相乘次序。 来自:计导引...
    距阵链乘问题: 找出矩阵链乘A(35*40) A(40*20) A(20*10) A(10*15)的最佳相乘次序。 算法来自:计算机算法导引-matrix chain by : identify matrix chain by A (35* 40) A (40* 20) A (20* 10) A (10* 15) concludes the best order. Algorithm from : computer algorithm Seeker
    2022-03-14 17:46:13下载
    积分:1
  • 与干扰
    With the interference-to-noise ratio reduced to 30 dB, plot the adaptive antenna pattern after 200 iterations of the LMS algorithm-With the interference-to-noise ratio of red uced to 30 dB. plot the adaptive antenna pattern after 200 ite rations of the LMS algorithm
    2023-03-06 19:50:03下载
    积分:1
  • 双色球随机软件源码
    void CRandDlg::OnOK()  { // TODO: Add extra validation here int a[7]; int b=0; srand((unsigned)time( NULL ));  for (int i=0;i
    2022-03-24 20:24:18下载
    积分:1
  • 邮政运输 2007年D题 邮政运输网络中的邮路规划和邮车调度 数学建模题目...
    邮政运输 2007年D题 邮政运输网络中的邮路规划和邮车调度 数学建模题目-Post transport D title in 2007 the postal routes in the transport network planning and scheduling Postal mathematical modeling topics
    2022-07-04 14:24:58下载
    积分:1
  • 军团问题, 某国家在一条战线上(一条直线)上部署了n 支军队。如果两支或两支以上军队相邻,它们将形成一个军团。如果一支军队不和任何一支军队相邻,那么它也是一个独...
    军团问题, 某国家在一条战线上(一条直线)上部署了n 支军队。如果两支或两支以上军队相邻,它们将形成一个军团。如果一支军队不和任何一支军队相邻,那么它也是一个独立的团。给定一组军队在战线上左右两端的位置及编号,求出所有的军团 -Corps issues, a country in a front (a straight line) on n-support forces deployed. If two or more than two neighboring armies, they will form a regiment. If an army is not adjacent to any one army, then it is also an independent regiment. Given a group of troops on the front left and right ends of the location and number, find all of the Army
    2022-02-28 17:22:05下载
    积分:1
  • 北理工的恶龙
    北理工的恶龙 背景: 最近,北理工出现了一只恶龙,它长着很多头,而且还会吐火,它将会把北理工烧成废墟, 于是,校长下令召集全校所有勇士杀死这只恶龙。要杀死这只龙,必须把它所有的头都砍掉,每个勇士只能砍一个龙头,龙的每个头大小都不一样,一个勇士只有在身高不小于龙头的直径的情况下才能砍下它。而且勇士们要求,砍下一个龙头必须得到和自己身高厘米数一样的学分。校长想花 最少的学分数杀死恶龙,于是找到你寻求帮助。 输入: 第一行 龙头数 n , 勇士人数 m ( 1
    2022-11-13 07:30:04下载
    积分:1
  • VTK读取STL文件
    是独立媒体网络一个免费的,开源的代码基方案,它的同盟者将提供“下一代”可信赖的多语言开放出版,包括增强的安全和秘密、用户化、企业联合组织和分布式(点对点)多媒体存储,搜索和流动。这里利用了VTK函数获取STL数据,并且实现了实体的移动和变换
    2022-07-19 17:48:55下载
    积分:1
  • 超级C语言小游戏,转的
    超级C语言小游戏,转的-small games, the switch
    2022-06-27 22:06:58下载
    积分:1
  • 哈夫曼压缩文件解压缩
    哈夫曼压缩解压缩文件。使用自适应哈夫曼,在 *.asv 文件中,这可以解压缩压缩保存的所有文件类型。包含的所有文件。
    2022-07-16 08:40:07下载
    积分:1
  • 696518资源总数
  • 105065会员总数
  • 14今日下载