7829: CCC '08 S4 - Twenty-four
[Creator : ]
Description
Canadian Computing Competition: 2008 Stage 1, Senior #4
Twenty-four is a popular card game designed to be played by four pla((A*K)−J)∗Q
((1∗13)−11)∗12
The first pla
Each valid arithmetic ex
Non-integer quotients of division are also not allowed, even as a partial result (of a subex
In some cases, the pla
Input
The first line contains an integer $N\ (1≤N≤5)$ indicating the number of card hands that follow.
Each hand consists of four lines. Each of these lines is an integer $C\ (1≤C≤13)$ indicating the value of a card.
Each hand consists of four lines. Each of these lines is an integer $C\ (1≤C≤13)$ indicating the value of a card.
Output
For each hand, output a line containing an integer $n$ if the cards can be combined using arithmetic operators to evaluate to $n$.
The value $n$ should be the largest possible value amongst all possible arithmetic expressions using these 4 cards, so long as $n≤24$.
The value $n$ should be the largest possible value amongst all possible arithmetic ex
Sample 1 Input
3
3
3
3
3
1
1
1
1
12
5
13
1
Sample 1 Output
24
4
21