Topic Link:
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_ problem&problem=1285
Type: Backtracking
Original title:
Your task is to write a program so can decide whether can find a arithmetic expression consisting of five given Num Bers
(1<=i<=5) That would yield the value 23. For this problem we'll only consider arithmetic expressions of the following from:
: {1,2,3,4,5}-> {1,2,3,4,5} is a bijective function
{+,-,*} (1<=i<=4)
Sample input:
1 1 1 1 1
1 2 3 4 5
2 3 5 7 11
0 0 0 0 0
Sample output:
Impossible
Possible
Possible
The main effect of the topic:
The question is better, the rules of the game and playing cards "count 24 points" basically the same.
The rule is this: give you 5 cards, and then ask you to use +,-, * These three symbols, to calculate these 5 numbers, so that their sum is 23.
You have to program to determine whether all 5 cards can achieve 23 points.
Ideas and Summary:
This game believes that many people have played in childhood, if a child can be a small program to help us, then. It's going to be programmed or something.
At least you can cheat children ...
If you use the computer to do with the recursive backtracking algorithm, then it will be very simple thing, only need to violently search out all the permutations, with all the symbols,
You can easily get the answer