RPRECEDE - Reverse Precedence

no tags 

Description

What if arithmetic operator precedence were reversed? Could you handle it?
Expressions within parentheses is still evaluated first, but + and - precede * and /.
Like with traditional arithmetic, "ties" (e.g. + and -) are evaluated in the order they appear.

Input

A valid arithmetic expression, using positive decimal integers, parentheses, and the operators +, -, and *.
Intermediate values are guaranteed never to exceed +- 1,000,000,000.

Output

The value of the expression.
Input Input
2 * 1 + 1
(20) * (2 + 1) + 1
Output Output
4
80
Use stacks.


Added by:BYU Admin
Date:2014-03-01
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET