Twenty-four

来源:互联网 发布:詹姆斯每个赛季数据 编辑:程序博客网 时间:2024/04/28 18:22

Description

There are 8 cards :1 1 2 2 3 3 4 4, you need to find out how many ways are there to choose 4 cards and these 4 cards can be used to play the game twenty-fourAttention, there is no difference between cards with the same number, 1 2 2 3 and 1 2 2 3 will be regarded as one solution, etc.

 

Hint: twenty-four is a game in which you are given 4 cards marked with numbers, and you may use +, -, * to connect all the four cards and make the result to be 24.

Input
No input in this problem.
Output
Output the result in one line. 
Sample Input
Sample Output
It’s what you need to output. :)
这个题目不知道要不要贴上来。。。为了水经验还是写上来吧。太坑了。

题意:有八张卡牌,任取四张通过+。-。*三种运算使结果等于24即可,问有多少种取法。任意两张相同数值卡牌视为同一种...

我最开始就直接枚举,然后一个个看能不能满足24.毕竟24=24*1=12*2=8*3=6*4。很简单能够套出答案有13种。马上输出13空行。提交。结果Wa了。为什么!!!然后我以为我理解错了,求解大神...fushihui大神马上指明一条“明路”--不能有括号?晕。反正最后答案还是出来了,是13!!!没有空行。还是太年轻了。

cout<<13<<endl;


0 0
原创粉丝点击