#P1834. 速算游戏

速算游戏

Description

jyx and cyy made a bet to see who can compute 2424 faster; the slower person treats. The rules of the 2424 Game are as follows: given 44 integers from 191\sim 9, use parentheses to change the order of operations and perform a sequence of operations among addition, subtraction, multiplication, and division to obtain the integer 2424.

Note that all intermediate results must be integers (for example, (2×2)/4(2\times 2)/4 is allowed, while 2×(2/4)2\times (2/4) is not allowed).

To win this match, please write a program to help me cheat by quickly computing 2424.

Input Format

One line with 44 integers, which are the given 44 numbers. The input testdata is guaranteed to have a solution.

Output Format

One line, output the result as a string. Make sure to include parentheses for every step of the operations (for example, (3+5)+6(3+5)+6 and 3×(5+6)3\times(5+6)). If there are multiple solutions, output the lexicographically smallest one.

2 3 5 7 
(((3*5)+2)+7)

Hint

Translated by ChatGPT 5