#K58877. Apply Operations on an Expression String

    ID: 30740 Type: Default 1000ms 256MiB

Apply Operations on an Expression String

Apply Operations on an Expression String

You are given a string that encodes a series of numerical operations. The string consists of a sequence where each operation is represented by an operator (either +, -, *, or /) immediately followed by an integer. Starting with an initial value of (0), apply each operation in sequence to obtain the final result.

For example, consider the string: +3+2-4*5.

We start with (0): [ 0 \xrightarrow{+3} 3 \xrightarrow{+2} 5 \xrightarrow{-4} 1 \xrightarrow{*5} 5 ]

Note that division ( / ) should be interpreted as integer division (floor division when both operands are non-negative), and all operations are processed from left to right without any precedence rules.

Your task is to implement a function to compute the final result after applying all the operations given as a string.

inputFormat

Input is provided via standard input (stdin) as a single line containing a string that represents the sequence of operations. For example: +3+2-4*5.

outputFormat

Output the final result as an integer to standard output (stdout).## sample

+3+2-4*5
5