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

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

于 2022-04-21 发布 文件大小:135.46 kB
0 138
下载积分: 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 个回复

  • 数据结构习题
    数据结构非常经典的练习题,里面有1800道习题,其中有各种算法的习题、还有代码可以练习,可以供学习者学习参考,对于将来工作笔试都有一定的帮助作用。
    2022-12-11 10:10:03下载
    积分:1
  • File contains the steepest descent algorithm, least
    文件包含最速下降算法,最小二乘算法,霍夫曼编码-File contains the steepest descent algorithm, least-squares algorithm, Huffman coding
    2023-07-30 23:10:03下载
    积分:1
  • 这个程序可实现最优二分检索树的构造,绘制和检索,请在Turboc 2.0下运行...
    这个程序可实现最优二分检索树的构造,绘制和检索,请在Turboc 2.0下运行-this procedure can achieve optimal two-tree structure retrieval, mapping and retrieval, please run Turbo 2.0
    2022-11-05 10:00:03下载
    积分:1
  • 关于一些中如何生成新成员的选择方,粒子群,遗传可以用。...
    关于一些算法中如何生成新成员的选择方法,粒子群算法,遗传算法等算法可以用。-How about some algorithm to generate a new member of the selection method, particle swarm optimization, genetic algorithms and other algorithms can be used.
    2023-03-07 06:40:03下载
    积分:1
  • WINCE API函数简介
    1. API之网络函数; 2. API之消息函数; 3. API之文件处理函数; 4.API之打印函数; 5. API之文本和字体函数;  6. API之菜单函数;   7. API之位图、图标和光栅运算函数;8. API之绘图函数;  9. API之设备场景函数;   10. API之硬件与系统
    2022-08-05 21:53:56下载
    积分:1
  • C 二叉搜索树的数据结构编程练习
    这是一个在大学课堂数据结构课堂中学生练习的一个关于树这个特殊的数据结构的课堂练习,这个代码应用了二叉树的建树,先根,后跟、以及中跟搜索的算法
    2022-04-17 23:30:39下载
    积分:1
  • 匿名四轴飞行器
    匿名四轴飞行器代码,分部讲解,带注释,匿名四轴飞行器代码,分部讲解,带注释,
    2022-01-30 20:54:04下载
    积分:1
  • 八皇后问题
    /////////////////////////////////////////////////// // 八皇后问题 // 循环实现, 共有92个解 // 命令窗口显示 请点击左侧文件开始预览 !预览只提供20%的代码片段,完整代码需下载后查看 加载中 侵权举报
    2023-08-08 01:40:03下载
    积分:1
  • 一个程序来寻找频繁项集(关闭和最大)与Eclat
    A program to find frequent itemsets (also closed and maximal) with the eclat algorithm ,which carries out a depth first search on the subset lattice and determines the support of itemsets by intersecting transaction lists. -A program to find frequent itemsets (also c losed and maximal) with the eclat algorithm, which carries out a depth first search on the sub set lattice and determines the support of items ets by intersecting transaction lists.
    2022-02-20 07:32:43下载
    积分:1
  • 简单的二叉树实现
    简单的二叉树实现-achieve simple binary tree
    2022-04-18 05:40:38下载
    积分:1
  • 696518资源总数
  • 105873会员总数
  • 12今日下载