1530: Interesting Card Game [有趣的纸牌游戏]
Time Limit: 2000 ms Memory Limit: 32000 kB
Judge type: Multi-cases Special Judge (Detailed Mode - 10 cases)
Total Submit : 340 (69 users) Accepted Submit : 110 (55 users) Page View : 2967
Whenever going to other places for contests, the ACM team of Nankai University always takes along a pack of cards to kill time on the train.
The rule of the card game is very simple. Before the game starts, the jokers are taken out from the cards. And then, 4 pieces of cards are taken out and shown each time. "A" stands for 1. "J" stands for 11. "Q" stands for 12. "K" stands for 13.Then, every player tries to join the four numbers with "+", "-", "*", "/", "(", ")" into an arithmetic expression which equals to 24. The winner is the one who figures out the correct arithmetic expression or confirms no solution for the four cards most quickly. Of course, each card must be used and could only be used once only.
Now, could you design a program to win the interesting card game more easily?

Input
Input contains several cases. The input is ended up with the end of file (EOF).
Each case contains only one line which includes only four integers, standing for the four cards taken out. The integers are between 1 and 13. (including 1 and 13) And the four integers will be separated from each other by a blank.Output
For each case, please output two lines.
The first line for the i-th input case should be "Case i:", and the second line should be an arithmetic expression which satisfies the rule, and anyone is acceptable, if there are no less than one solution. If no solution exists, just output "No Solution!" in the second line of the case.
For an arithmetic expression, extra brackets are allowed. Take cards "1" , "2", "3" and "4" for example, the following arithmetic expressions are all accepted:
(1+2+3)*4
(((1+2)+3)*4)
1*2*3*4Sample Input
1 2 3 4 1 1 1 1
Sample Output
Case 1: (1+2+3)*4 Case 2: No Solution!
代码看看吧: 我先全排列 然后符号循环检测 再前两个和后两个另外检测
写的很破 如果谁有好的写的 马上发我邮箱吧 谢谢~~~