Quantcast
Channel: 《2010 = 1+2-(3-4-5)*6*7*8-9》的评论
Browsing all 15 articles
Browse latest View live

作者:Favorites

<a href="#comment-2853" rel="nofollow">@gugaotianshi</a> 我以前也想过,也不知道怎么做。

View Article


作者:王二

用PHP写过算24点的

View Article


作者:王二

<blockquote cite="#commentbody-2869"> <strong><a href="#comment-2869" rel="nofollow">王二</a> :</strong> 用PHP写过算24点的 </blockquote> 代码看这里:http://code.google.com/p/24game/

View Article

作者:chassic

我认为如果有使用表达式解析器,只要穷举所有表达式,依次计算。这种方法的话基本无难度

View Article

作者:gugaotianshi

表达式解析器? Lisp 之类的函数编程语言天生的。 不过,穷举所有表达式也不容易啊,主要是那个N对的括号- – ———– 我现在想到的是把 2010 分成两个数,即: 2010 = f(x,y) 如 2010 = 1 + 2009 之后再递归迭代 1 = f(x’,y’), 2009 = f(x”,y”)。 然后,每次迭代,都会尝试去求得 x 与 y 在即有条件下是否可以构造成功。...

View Article


作者:ruiqi

围观。。。这题目很久前搞过一些~~~现在不行了。。code少了~~

View Article

作者:ostric

大脑栈溢出了。。。

View Article

作者:Frank

花了大概一天时间,终于写好了一个将字符串型的四则运算表达式计算出double型结果的东西了。有点小成就感,呵呵。

View Article


作者:tengdong

牛人!

View Article


作者:古歌

<blockquote cite="#commentbody-2874"> <strong><a href="#comment-2874" rel="nofollow">chassic</a> :</strong> 我认为如果有使用表达式解析器,只要穷举所有表达式,依次计算。这种方法的话基本无难度 </blockquote>...

View Article

作者:JackalDire

编程之美,二十四点。 本质都是穷举加上剪枝优化

View Article

作者:_fish

博主说的是只使用加减乘除还有括号,哪来的点号啊?

View Article

作者:hecha

做了一个 python 的简单实现,处理了使用单个数的情况,结果中会有些重复 def f(n): if len(n) == 1: yield n[0], str(n[0]) else: for i in range(1, len(n)): nx, ny = n[:i], n[i:] for x, ex in f(nx): for y, ey in f(ny): yield x + y, ‘(‘ +...

View Article


作者:wolfking

想了种方法,不懂可不可行… 随机生成数字之间的运算符号-> 判断合法性->判断表达式的值是否等于2010,相等就输出表达式。运行足够的时间应该是可以生成结果的吧

View Article

作者:supersheep

遍历是一个指数复杂度的问题,“足够”的时间是不可能的。。。<a href="#comment-120202" rel="nofollow">@wolfking </a>

View Article

Browsing all 15 articles
Browse latest View live