TheArithmeticProgression
SRM 591 · 2013-06-25 · by gojira_tc
Problem Statement
You are given three
Constraints
- a will be between 0 and 1000, inclusive.
- b will be between 0 and 1000, inclusive.
- c will be between 0 and 1000, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
0 1 2 Returns: 0.0
The triple (0, 1, 2) is an arithmetic progression. Thus, you can choose r = 0.0 and add or subtract it from any of the given numbers without changing the triple.
0 2 1 Returns: 1.5
Note that while (0, 1, 2) is an arithmetic progression, you cannot rearrange the numbers within the triple. You can choose r = 1.5 and subtract it from b, obtaining the triple (0, 0.5, 1).
3 2 1 Returns: 0.0
4 4 8 Returns: 2.0
1000 0 0 Returns: 500.0
Submissions are judged against all 61 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheArithmeticProgression with a public method double minimumChange(int a, int b, int c) · 61 test cases · 2 s / 256 MB per case