Parallelogram
Time limit2sMemory limit128 MB
Given three points, find the difference between the largest and smallest perimeter among all parallelograms that use the three points and one extra point D.
- Level
Medium4 of 10
- Topics
- Geometry, Math, Brute force
- Solved
- No attempts yet
Problem
A parallelogram is a quadrilateral whose two pairs of opposite sides are parallel. Three distinct points A(x_A, y_A), B(x_B, y_B), and C(x_C, y_C) are given.
Choose a point D, if possible, so that the four points form a parallelogram. There may be more than one possible point D.
Among all parallelograms that can be formed, output the difference between the largest perimeter and the smallest perimeter. If no parallelogram can be formed, output -1.
Input
The first line contains six integers x_A y_A x_B y_B x_C y_C. The absolute value of each coordinate is at most 5000.
Output
Print the answer on the first line. An absolute or relative error of at most 10^-9 is accepted.