Under construction

Still being built. Things may change

Parallelogram

Time limit2sMemory limit128 MB

Summary
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.

Examples5

  1. Example 1

    Input
    0 0 0 1 1 0
    
    Expected output
    0.8284271247461898
    
  2. Example 2

    Input
    0 0 4 0 0 3
    
    Expected output
    4.0
    
  3. Example 3

    Input
    0 0 1 0 47 0
    
    Expected output
    -1.0
    
  4. Example 4

    Input
    1 2 3 4 8 7
    
    Expected output
    11.547796284592874
    
  5. Example 5

    Input
    2 -1 -7 2 -1 0
    
    Expected output
    -1.0