#SCKTIFELSE0000003. Máy tính bốn phép (Four-Operation Calculator)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Máy tính bốn phép (Four-Operation Calculator)
Four-Operation Calculator
Version: Phuoc Hung OJ Extended
Problem Statement
A basic calculator receives two integers and and an operator . The symbol + requests , - requests , * requests , and / requests . Division by zero is not allowed. When division is valid, the result must be displayed with exactly two digits after the decimal point. Perform the requested operation.
Input
The first line contains two integers and , separated by a space. The second line contains one operator from {+, -, *, /}.
Output
For +, -, or *, print the corresponding integer result. For / with , print KHONG_CHIA_DUOC. For / with , print the quotient with exactly two digits after the decimal point using Python-style fixed-point formatting; when , print 0.00.
Subtasks
-
Subtask 1 (20 points): ;
-
Subtask 2 (30 points): ;
-
Subtask 3 (50 points): ; $p\in\{\texttt{+},\texttt{-},\texttt{*},\texttt{/}\}$
Examples
Example 1
Input
8 3
+
Output
11
Explanation
The + operator requests .
Example 2
Input
8 3
/
Output
2.67
Explanation
The divisor is , so ; formatting to two decimal places gives 2.67.
Example 3
Input
9 0
/
Output
KHONG_CHIA_DUOC
Explanation
The operator / requests division but , so division cannot be performed.
Liên quan
Trong các cuộc thi sau: