#C8247. Arithmetic Expression Evaluation

    ID: 52208 Type: Default 1000ms 256MiB

Arithmetic Expression Evaluation

Arithmetic Expression Evaluation

Given an arithmetic expression containing integers, the operators +, -, *, and /, as well as parentheses ( and ), evaluate the expression and output the resulting integer. The expression may include spaces, which should be ignored. The operations follow standard operator precedence, and division is performed as integer division (i.e., the result is truncated towards zero).

For example, the following expressions evaluate as:

  • \(3 + 5 = 8\)
  • \(10 + 2 * 6 = 22\)
  • \(100 * (2 + 12) = 1400\)
  • \(100 * (2 + 12) / 14 = 100\)

inputFormat

Input is provided via standard input (stdin). The input consists of a single line containing an arithmetic expression. The expression includes integers, the operators +, -, *, /, and may contain parentheses and arbitrary spaces.

outputFormat

Output the evaluated integer result to standard output (stdout).## sample

3 + 5
8