Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0128 - SHOW ME THE

   A programming instructor needs your help to teach his students on precedence level of binary arithmetic operators (+, -, *, /). Write a program which can show the sequence of operators executed when evaluating an arithmetic expression according to the precedence rules below.

   Precedence rules:

(1)   Multiplication and division operators have higher precedence than plus and minus operators

(2)   Multiplication and division operators have the same level of precedence. However, in an expression, the operator which appears first from the left of the expression has higher precedence.

(3)   Plus and minus operators have the same level of precedence. However, in an expression, the operator which appears first from the left of the expression has higher precedence.

   Evaluation of expression starts from left to right.

Input

   The first line of the input data contains an integer which represents the number of test cases. The line is then followed by the data for each of the test cases. Each test case contains an arithmetic expression containing mixture of positive integer operands and binary arithmetic operators (with a space in between). For simplicity, let’s assume the maximum number of operators in an expression is limited to 10.

Output

   The output comprises of one line for each test case (arithmetic expression). The line begins with prefix “Case #x:” where x represents the case number, followed by the output of the test case. For each test case, a list of arithmetic operators will be produced according to the precedence they were executed in the expression. The list is terminated with the final result of the execution.

Examples

stdin

stdout

1

2

4 + 16 / 4 * 3 + 6 * 2

6 * 2 + 3 * 2 / 2

Case #1: / * * + + 28

Case #2: * * / + 15


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2014-02-07
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.Malaysia National 2013.D

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.