#PCBBAY0000010. So sánh tổng ba số theo hai cách (Exact and Approximate Sum Comparison)
So sánh tổng ba số theo hai cách (Exact and Approximate Sum Comparison)
Exact and Approximate Sum Comparison
Version: Phuoc Hung OJ Extended
Problem Statement
Given four real numbers , , and , compute as Python float, in left-to-right evaluation order. Report the result of exact equality s == target and then the default approximate comparison math.isclose(s, target). The two answers may differ.
Input
The only line contains four real numbers , , and , in that order.
Output
Print exactly two lines: the True/False result of s == target on line 1 and of math.isclose(s, target) on line 2.
Subtasks
- Subtask 1 (100 points): All four inputs are finite.
Examples
Example 1
Input
0.1 0.1 0.1 0.3
Output
False
True
Explanation. Left-to-right floating-point addition gives s = 0.30000000000000004. Exact comparison with 0.3 yields False; the default approximate comparison yields True.
Example 2
Input
0.5 0.5 0.5 1.5
Output
True
True
Explanation. Left-to-right floating-point addition gives s = 1.5. Exact comparison with 1.5 yields True; the default approximate comparison yields True.
Example 3
Input
0.2 0.2 0.2 0.6
Output
False
True
Explanation. Left-to-right floating-point addition gives s = 0.6000000000000001. Exact comparison with 0.6 yields False; the default approximate comparison yields True.