#154. 数字远近判断
数字远近判断
Close Far
Background
Congcong is currently studying the distance relationships between numbers. He wants to determine if three given integers satisfy a specific "close" and "far" condition.
Problem Description
Given three integers, , , and , return true if one of or is "close" (differing from by at most 1), while the other is "far" (differing from both other values by 2 or more). Note: computes the absolute value of a number.
Input Format
Input consists of a single line containing three integers , , and .
Output Format
Output true if the condition is met, otherwise output false.
trueorfalse
Sample
1 2 10
true
1 2 3
false
4 1 3
true
Sample Explanation
Sample 1: .
is close to , because .
is far from , because .
is far from , because .
Therefore, one is close and the other is far, returning true.
Sample 2: . Check the case where is close to and is far: (satisfies is close to ). (satisfies is far from ). (does not satisfy is far from ). So this case is false.
Check the case where is close to and is far:
(does not satisfy is close to ).
So this case is false.
Neither case is true, returning false.
Sample 3: . Check the case where is close to and is far: (does not satisfy is close to ). So this case is false.
Check the case where is close to and is far:
(satisfies is close to ).
(satisfies is far from ).
(satisfies is far from ).
So this case is true, returning true.
Constraints
Time limit: 1s, Memory limit: 1024KiB for each test case.