#C12312. Sequential Calculator

    ID: 41726 Type: Default 1000ms 256MiB

Sequential Calculator

Sequential Calculator

You are required to implement a sequential calculator. Starting from an initial value of 0, process a sequence of operations one by one. Each operation is represented by an operator and an operand. The supported operators are addition (+), subtraction (-), multiplication (*), and division (/).

For a division operation, if the operand is 0, the calculator should immediately output the current result without processing any further operations. Otherwise, perform the division normally.

The division operation is defined as: \( result = \frac{result}{value} \) for \( value \neq 0 \).

inputFormat

The first line of the input contains an integer \( n \) representing the number of operations. Each of the next \( n \) lines contains an operation in the format:

operator value

where operator is one of +, -, *, or /, and value is an integer.

outputFormat

Output the final result after processing all operations. The result can be an integer or a floating point number. If a division by zero is encountered, output the result immediately without further processing.

## sample
4
+ 5
- 3
* 10
/ 2
10.0