-
一、前言
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
-
八皇后问题的解法,非常好,请大家看一下,谢谢了
八皇后问题的解法,非常好,请大家看一下,谢谢了-8 Queen" s problem solution, very good, please look at, I would like to thank the
- 2022-01-28 01:59:41下载
- 积分:1
-
graphics rendering 3D graphics
图形学中三维图形的绘制-graphics rendering 3D graphics
- 2022-10-21 11:30:03下载
- 积分:1
-
数值分析第八版的负担和菲尔斯
Numerical Anaysis 8th Edition Burden and Faires
- 2022-03-11 13:44:04下载
- 积分:1
-
快速排序算法,很好用,用c++编,拷贝在文本里,大家可以参考参考哦....
快速排序算法,很好用,用c++编,拷贝在文本里,大家可以参考参考哦.-quick sort algorithm is useful, with c writers, copy in the text, one can refer to Reference oh.
- 2022-04-26 15:23:24下载
- 积分:1
-
阳历转阴历
阳历转阴历,在软件开发里经常用到。特别是生日推算,用阳历推阴历。一个很不算的算法,很实用,直接拿来用,省了不少事。
- 2022-03-04 08:05:02下载
- 积分:1
-
在电压过零点触发或截至可控硅的导通或闭合;有效通断电压;应用稳定可靠;...
在电压过零点触发或截至可控硅的导通或闭合;有效通断电压;应用稳定可靠;-Triggering voltage zero-crossing point or at the turn-on SCR or closed the effective on-off voltage application of stable and reliable
- 2022-03-14 03:45:10下载
- 积分:1
-
- 2022-04-26 09:25:16下载
- 积分:1
-
神经网络
本代码实现如何反向传播算法 works.it 将生成关系图,它会告诉准确的预测和实际的输出结果。
- 2022-08-10 12:08:51下载
- 积分:1
-
经典的基于vc++的小波滤波程序。很适合作信号处理的朋友
经典的基于vc++的小波滤波程序。很适合作信号处理的朋友-Based on the classic vc++ The wavelet filtering procedure. Very suitable for signal processing Friend
- 2022-01-22 07:03:50下载
- 积分:1