#P1834. 速算游戏
速算游戏
Description
jyx and cyy made a bet to see who can compute faster; the slower person treats. The rules of the Game are as follows: given integers from , use parentheses to change the order of operations and perform a sequence of operations among addition, subtraction, multiplication, and division to obtain the integer .
Note that all intermediate results must be integers (for example, is allowed, while is not allowed).
To win this match, please write a program to help me cheat by quickly computing .
Input Format
One line with integers, which are the given 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, and ). If there are multiple solutions, output the lexicographically smallest one.
2 3 5 7
(((3*5)+2)+7)
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号