|
|||
Camel TradingIn around 800 AD, El Mamum, Calif of Baghdad, was presented the formula 1+2*3*4+5, which had its origin in the financial accounts of a camel transaction. The formula lacked parentheses and was ambiguous. So, he decided to ask savants to provide him with a method to find which interpretation is the most advantageous for him, depending on whether he is buying or selling the camels. You are commissioned by El Mamum to write a program that determines the maximum and minimum possible interpretation of a parentheses-less expression. Input Specification
The input consists of an integer N, followed by N lines, each containing an
expression. Each expression is composed of at most 12 integers, each ranging between 1 and 20,
separated by the sum and product operators Output SpecificationFor each given expression, the output should echo a line with the corresponding maximal and minimal interpretations, following the format given in the sample output. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |