#CCBCHMUOI0000029. Máy tính có phép chia (Calculator with Division)
Máy tính có phép chia (Calculator with Division)
Calculator with Division
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A calculator receives two integers a and b followed by an operator op from +, -, * and /. Compute the indicated operation. Division is C integer division, truncating toward zero; division by zero prints ERROR.
Input
One line contains a, b and then a single operator character op.
Output
Print the integer result or exactly ERROR if op is / and b = 0.
Subtasks
- Subtask 1 (20%): -10 <= a,b <= 10, op is + or -.
- Subtask 2 (30%): -1000 <= a,b <= 1000, op is +, -, * or /.
- Subtask 3 (50%): -10^6 <= a,b <= 10^6, op is +, -, * or /.
Examples
Example 1
Input
7 0 /
Output
ERROR
Explanation
The divisor is zero, so print ERROR.
Example 2
Input
-7 2 /
Output
-3
Explanation
C truncates -3.5 toward zero to -3.