#154. 数字远近判断

    ID: 154 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatLogic-2gesp1条件结构数学基础

数字远近判断

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, aa, bb, and cc, return true if one of bb or cc is "close" (differing from aa by at most 1), while the other is "far" (differing from both other values by 2 or more). Note: abs(num)abs(num) computes the absolute value of a number.

Input Format

Input consists of a single line containing three integers aa, bb, and cc.

aa bb cc

Output Format

Output true if the condition is met, otherwise output false.

true or false

Sample

1 2 10
true
1 2 3
false
4 1 3
true

Sample Explanation

Sample 1: a=1,b=2,c=10a=1, b=2, c=10. b=2b=2 is close to a=1a=1, because 21=11|2-1|=1 \le 1. c=10c=10 is far from a=1a=1, because 101=92|10-1|=9 \ge 2. c=10c=10 is far from b=2b=2, because 102=82|10-2|=8 \ge 2. Therefore, one is close and the other is far, returning true.

Sample 2: a=1,b=2,c=3a=1, b=2, c=3. Check the case where bb is close to aa and cc is far: 21=11|2-1|=1 \le 1 (satisfies bb is close to aa). 31=22|3-1|=2 \ge 2 (satisfies cc is far from aa). 32=12|3-2|=1 \ge 2 (does not satisfy cc is far from bb). So this case is false.

Check the case where cc is close to aa and bb is far: 31=21|3-1|=2 \le 1 (does not satisfy cc is close to aa). So this case is false. Neither case is true, returning false.

Sample 3: a=4,b=1,c=3a=4, b=1, c=3. Check the case where bb is close to aa and cc is far: 14=31|1-4|=3 \le 1 (does not satisfy bb is close to aa). So this case is false.

Check the case where cc is close to aa and bb is far: 34=11|3-4|=1 \le 1 (satisfies cc is close to aa). 14=32|1-4|=3 \ge 2 (satisfies bb is far from aa). 13=22|1-3|=2 \ge 2 (satisfies bb is far from cc). So this case is true, returning true.

Constraints

Time limit: 1s, Memory limit: 1024KiB for each test case.