#K80702. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a mathematical expression as a non-empty string containing non-negative integers and the operators \( + \), \( - \), \( \times \) (represented by *
) and \( \div \) (represented by /
). The task is to compute the evaluation of the expression following the standard order of operations, i.e. multiplication and division are performed before addition and subtraction, and operations with the same precedence are evaluated from left to right. Note that division is integer division (i.e. the quotient is an integer).
For example, for the expression \(3+5*2\), the multiplication is evaluated first resulting in \(5*2=10\), then the addition gives \(3+10=13\).
inputFormat
The input consists of a single line containing a string that represents the mathematical expression. The expression contains only non-negative integers and the operators +
, -
, *
, and /
(with no spaces).
outputFormat
Output a single integer as the result of evaluating the expression using integer division.
## sample3+5*2
13