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

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

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

  • 国产stc89c51对应矩阵键盘
    资源描述在键盘中按键数量较多时,为了减少I/O口的占用,通常将按键排列成矩阵形式。在矩阵式键盘中,每条水平线和垂直线在交叉处不直接连通,而是通过一个按键加以连接。这样,一个端口(如P1口)就可以构成4*4=16个按键,比之直接将端口线用于键盘多出了一倍,而且线数越多,区别越明显,比如再多加一条线就可以构成20键的键盘,而直接用端口线则只能多出一键(9键)。
    2022-10-02 19:00:03下载
    积分:1
  • 关于河内塔的一个术分辨率。采用Visaul C++编译
    河内塔的数学解析。用VisualC++编写
    2022-05-26 09:11:12下载
    积分:1
  • 利用有限元流体计求解器的准备,包括你的使用…
    一个用fortran90编写有限元流体求解器,包括使用源代码,输出文件和单元文件,推荐学习使用-Prepared using a finite element fluid fortran90 solver, including the use of source code, the output file and the unit document and recommend learning to use
    2022-02-03 11:34:16下载
    积分:1
  • 一个有关进制的和程序,它将一定范围内的数编制成组,通过从二进位制到十进位制, 进行编组,输入进制数和组数,即可自动计出数据,并显示在屏幕上,同时输出到文件...
    一个有关进制的和程序,它将一定范围内的数编制成组,通过从二进位制到十进位制, 进行编组,输入进制数和组数,即可自动计算出数据,并显示在屏幕上,同时输出到文件中,是很不错的程序,我用了好几天才编好,很精悍!-one of the 229 and procedures, it would certainly within the scope of the report into several groups, By binary system to the decimal system, organization, and the importation of 229 for a group, they will automatically calculate data, displayed on the screen, while the output to a file, is a very good procedure, I spent several days prepared and very lean!
    2022-09-10 07:35:02下载
    积分:1
  • 操作系统中的多级反馈队列调度
    操作系统中的多级反馈队列调度算法-operating system as a multi-level feedback queue scheduling algorithm
    2022-10-13 21:30:02下载
    积分:1
  • 子例程 ABAQUS 第 3 部分 VDI 指引 2014年纤维增强复合材料的强度分析
    此子程序用于强度分析of纤维增强复合材料 与的帮助下 有限元方法求解 ABAQUS / 标准.计算用于为三维应力状态根据 VDI 指引 2014年 , 部分 3.输入变量是基本优势,边坡参
    2023-01-04 02:20:04下载
    积分:1
  • 这是一个代码,可以实现任意阶的幻方的计(6除外)
    这是一个代码,可以实现任意阶的幻方的计算(6除外)-This is a code that can be achieved any order of the magic square of terms (except 6)
    2022-04-19 07:13:32下载
    积分:1
  • Tic tac toe
    kelebihan, namun manusia tetap memiliki berbagai kelemahan seperti mudah lelah, mudah lupa, dipengaruhi emosi, subjektif, kurang teliti, malas, dan sebagainya. Kemudian muncul ide untuk menciptakan komputer sebagai alat bantu kerja agar lebih cepat, dan lebih akurat. Namun saat ini komputer tidak hanya mampu bertindak tetapi juga mampu berfikir sehingga muncul istilah Artificial Intellegence (AI) atau Kecerdasan Buatan. Minimax merupakan salah satu contoh dari Kecerdasan Buatan, minimax adalah suatu algoritma yang menggunakan teknik pencarian Depth-First Search dengan kedalaman terbatas. Adapun media yang cocok untuk penerapan algoritma minimax adalah permainan Tic-Tac-Toe, beberapa alasan mengapa Tic- Tac-Toe
    2022-07-03 14:15:32下载
    积分:1
  • 遗传程序均匀交叉,变异操作
    采用二进制Gray编码,采用基于轮盘赌法的非线性排名选择, 均匀交叉,变异操作,而且还引入了倒位操作!
    2022-06-01 12:10:32下载
    积分:1
  • 基于改进的粒子群的微电网运行优化
    微电网是近来比较热门的话题,对于微电网的运行优化也是当前研究的重点,主要就是通过粒子群优化算法与遗传算法进行求解最优控制方案,已达到最优运行。本文献对粒子群算法进行了改进,同时比较简单,适合初学者。
    2023-01-11 05:10:04下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载