登录
首页 » 算法 » 一、前言 24点游戏是一个常见游戏,出题者给出4个整数,要求答题者在指定时间内给出一个四则运算的表达式,恰好用上这这个整数各一次,计算结果为24,超出时间为...

一、前言 24点游戏是一个常见游戏,出题者给出4个整数,要求答题者在指定时间内给出一个四则运算的表达式,恰好用上这这个整数各一次,计算结果为24,超出时间为...

于 2022-04-21 发布 文件大小:135.46 kB
0 158
下载积分: 2 下载次数: 1

代码说明:

一、前言 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

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

发表评论

0 个回复

  • DSP方波过零点捕捉中断程序
    DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),DSP方波过零点捕捉中断程序(用于频率计时),
    2022-01-21 19:05:48下载
    积分:1
  • 小波变换所有常见例程,vc++下调试通过。适合科研人员和工程应用人员...
    小波变换所有常见例程,vc++下调试通过。适合科研人员和工程应用人员-Wavelet transform of all common routines, vc++ Adopted under the debugger. Suitable for the application of scientific research personnel and engineering staff
    2023-06-09 04:30:03下载
    积分:1
  • ZJU ACM 1093 实现速率较高, 主要是有一个buffer来实现
    ZJU ACM 1093 实现速率较高, 主要是有一个buffer来实现-ZJU ACM 1093 to achieve a higher rate, there is mainly a buffer to achieve
    2022-02-15 16:22:47下载
    积分:1
  • classic Chinese Remainder Theorem solving program, you have to import the soluti...
    经典的中国剩余定理求解程序,输入你所要解的同余式即可按定理求解!-classic Chinese Remainder Theorem solving program, you have to import the solution congruence theorems can be solved by!
    2022-02-24 09:16:20下载
    积分:1
  • 实现的是对经纬度的分秒转换为double类型的坐标
    实现的是对经纬度的分秒转换为double类型的坐标-Realization of the minutes and seconds of latitude and longitude is converted to double types of coordinates
    2022-06-30 07:52:31下载
    积分:1
  • 超长整数乘源程序
    超长整数乘法源程序-long integer multiplication source
    2022-07-20 14:55:39下载
    积分:1
  • Mie散射过程中粒子的吸收系数,对研究粒子散射问题有帮助...
    计算Mie散射过程中粒子的吸收系数,对研究粒子散射问题有帮助-calculated Mie scattering particles in the process of absorption, scattering particle research help
    2022-03-25 20:30:45下载
    积分:1
  • stable matching
    简单的稳定匹配算法实现,无bug Implement Gale-Shapley algorithm of the Stable Matching Problem in your favorite language, and give the matching result of attached ranking data (boys rankings.txt and girls rankings.txt), supposing that the ranking is sorted from high to low. (C++ source file gs make ranking.cc which generates the data is also supplied here.)  
    2023-02-04 07:15:03下载
    积分:1
  • 包括Pheromones Algorythm、Memory Algorythm和Hill Climbing Algorythm I,II,III在内的多个人工智...
    包括Pheromones Algorythm、Memory Algorythm和Hill Climbing Algorythm I,II,III在内的多个人工智能算法的实现-including Pheromones Algorythm, Memory Algorythm and Hill Climbing Algorythm I, II, III from the number of artificial intelligence algorithms to achieve
    2022-05-14 02:23:02下载
    积分:1
  • 三次样条插值
    三次样条插值-Cubic Spline Interpolation
    2023-05-12 14:45:03下载
    积分:1
  • 696516资源总数
  • 106432会员总数
  • 11今日下载