Submit | All submissions | Best solutions | Back to list |
LCPC1 - AP or NOT |
A triplet (x, y, z) is called an arithmetic progression if the equality y - x = z - y holds. You are given three integers a, b and c. Your goal is to change the triple (a, b, c) into an arithmetic progression. You are only allowed to change one of the three numbers. The change must proceed as follows: First, you choose a non-negative real (not necessarily integer) number r. Then, you either add r to one of the three given numbers, or you subtract r from one of them. Return the minimum value of r which allows you to create an arithmetic progression
Input
Input contains three integers in each line. Input is terminated when all the three numbers are zero . All the integers are less than equal to 10^18.
Output
Output contains 1 real number denoting the minimum change required to make the sequence an AP. Output must be rounded to 1 digit after the decimal point.
Example
Input: 4 4 8
0 0 0 Output: 2.0
Added by: | Aditya Dixit |
Date: | 2013-09-17 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |