A higher resolution is required to access the IDE
- 99
Statement
Goal
Your task is to output the screen of a calculator when a key is pressed. For example:-Input
-Input
-Input
-Input
-Input
-Input
-Input
-Input
-Input
The calculator doesn't take into account the priority of the operators. If the user presses:
the final output will be
The user may press two operation keys consecutively. In that case, the operation that must be taken into account is the second one.
If the result has decimal numbers, it must be output with, at most, 3 decimal places. Otherwise, it must be output without a decimal point. Decimal numbers are also stored rounded with 3 decimal places.
If the user presses the
Input
Line 1: An integer n for the number of keys to press.
Next n lines: A string that shows the key pressed.
Next n lines: A string that shows the key pressed.
Output
n lines: The output of the screen after each key is pressed
Constraints
The key will be one of these: 0 -9 , + , - , x , / , = , AC
Neither test cases nor validator will divide by zero. First key will always be a cipher.
Neither test cases nor validator will divide by zero. First key will always be a cipher.
Example
Input
7 2 5 + 6 - 7 =
Output
2 25 25 6 31 7 24
A higher resolution is required to access the IDE