#156. 判断三整数是否构成等差数列
判断三整数是否构成等差数列
Evenly Spaced Integers
Background
Dawei is studying the properties of number sequences. He wants to know if three given integers can form an arithmetic progression.
Problem Description
Given three integers . One of them is small, one is medium, and one is large. Return true if the three values are evenly spaced, meaning the difference between the small and medium number is the same as the difference between the medium and large number. Otherwise, return false.
To determine if they are evenly spaced, you should first sort the three numbers. Let the sorted numbers be (such that ). The condition to check is .
Input Format
Input is given from standard input in the following format.
Three integers .
Output Format
Output is printed to standard output in the following format.
Output
trueif the three numbers are evenly spaced; otherwise, outputfalse.
Sample
2 4 6
true
4 6 2
true
4 6 3
false
Sample Explanation
Sample 1: The input is . Sorted, they are . The difference between the small and medium number is , and the difference between the medium and large number is . The two differences are equal, so true is output.
Sample 2: The input is . Sorted, they are . The difference between the small and medium number is , and the difference between the medium and large number is . The two differences are equal, so true is output.
Sample 3: The input is . Sorted, they are . The difference between the small and medium number is , and the difference between the medium and large number is . The two differences are not equal, so false is output.
Constraints
Time limit: 1s, Memory limit: 1024KiB for each test case.