-
一、前言
24点游戏是一个常见游戏,出题者给出4个整数,要求答题者在指定时间内给出一个四则运算的表达式,恰好用上这这个整数各一次,计算结果为24,超出时间为...
一、前言
24点游戏是一个常见游戏,出题者给出4个整数,要求答题者在指定时间内给出一个四则运算的表达式,恰好用上这这个整数各一次,计算结果为24,超出时间为输。
二、分析
用计算机来算这个题,搜索速度当然有很大优势,我编程喜欢考虑通用一点,不限制输入数量和结果数,甚至不限制运算符数量。这样组合数就很大,如果输入数比较多,则搜索时间会非常长。
我用两个方法来提高搜索速度:一、是大家都能考虑到的重复搜索问题,比如1,2,3和2,3,1所有的组合情况是相同的,我只搜索使用递增序的数组,则可以降低一个组合数的数量级别;二、使用动态规划中的备忘录方法,比如你计算出2和3所有可能的计算结果,则他们与4结合的时候,要用到,与1结合的时候,也要用到,使用备忘录,可以只计算一次,大大降低运算复杂度。
三、设计
整体设计:分别设计4个类:游戏、表达式、运算、分数,各司其责,结构清晰,易于扩展。
-First, the preamble
24-point game is a common game, give the title are four integer requiring answer within a specified period of time in a four calculations give the expression, just use that the integral of the time, results for the 24, beyond the time to lose.
Second, analysis
Use computers to count the title, the search speed of course, there is a great advantage, I enjoy taking generic programming that does not restrict the importation of the volume and the number of results, and even limiting the number of operators. So on a large number of combinations, if you
- 2022-04-21 18:17:05下载
- 积分:1
-
设有n个人围做一圈,现从某个人开始报数,数到m的人出列,接着从出列的下一个人开始重新报数,数到m的人又出列,如此下去,直到所有人都出列为止。运用循环单链表解决约...
设有n个人围做一圈,现从某个人开始报数,数到m的人出列,接着从出列的下一个人开始重新报数,数到m的人又出列,如此下去,直到所有人都出列为止。运用循环单链表解决约瑟夫环问题。- Is equipped with n personally to encircle makes, presently
starts from some person to count off, leaves ranks the number to the m
person, meets from the next person which leaves ranks is starting reto
count off, leaves ranks the number to the m person, continue like
this, all leaves ranks until all people. Using circulates Shan
Lianbiao to solve the Joseph link problem.
- 2022-02-26 00:46:58下载
- 积分:1
-
快速傅立叶变换算法中的分裂基算法,又称基2/4算法,对一维序列,这种算法使FFT比较完善...
快速傅立叶变换算法中的分裂基算法,又称基2/4算法,对一维序列,这种算法使FFT比较完善-Fast Fourier Transform algorithm separatist base algorithm, also known as base 2/4 algorithm, the one-dimensional sequence, so FFT algorithm sound
- 2022-03-22 19:14:52下载
- 积分:1
-
利用黄金分割法求解线性方程组逼近问题。转载
利用黄金分割法求解线性方程组逼近问题。转载-The use of golden section method for solving linear equations approximation problem. Reprint
- 2022-01-21 20:42:19下载
- 积分:1
-
信号相位匹配原理的正弦信号参数的最小二乘估计
信号相位匹配原理的正弦信号参数的最小二乘估计-Parameter estimation of sinusoidal signals by using principle of signal matched-phase
- 2022-06-03 13:30:00下载
- 积分:1
-
TI DSP DM642图像处理程序,
TI DSP DM642图像处理程序,---直方图均衡-TI DSP DM642 image processing procedures,--- histogram equalization
- 2022-12-17 16:25:03下载
- 积分:1
-
单个文件在以下链接是可用的:
Individual files are available in the following links:
Bessjy -- Bessel functions Jn and Yn for real argument and integer or real order.
Bessik -- Modified Bessel function In and Kn for real argument and integer or real order.
CBessjy -- Bessel functions Jv and Yv for real or complex arguments and real order.
CBessik -- Modified Bessel functions Iv and Kv for complex arguments and real order.
-Individual files are available in the following links: Bessjy- Bessel functions Jn and Yn for real argument and integer or real order. Bessik- Modified Bessel function In and Kn for real argument and integer or real order. CBessjy- Bessel functions Jv and Yv for real or complex arguments and real order. CBessik- Modified Bessel functions Iv and Kv for complex arguments and real order.
- 2022-04-29 03:27:40下载
- 积分:1
-
一个很实用的保留小数程序
一个很实用的保留小数程序- A very practical retention decimal procedure
- 2022-03-23 05:05:24下载
- 积分:1
-
遗传算法优化
资源描述
多种群遗传算法,包括移民算子,人工选择算子,目标函数,标准遗传算法和多种群遗传算法的主函数,适合于群体智能算法的初学者,是经典的算法案例。
- 2022-01-31 00:46:50下载
- 积分:1
-
vc++基因比对算法代码
基因比对算法其中一个算法代码。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
- 2022-01-31 08:43:39下载
- 积分:1