Under construction

Still being built. Things may change

Drone With a Camera

Time limit1sMemory limit256 MB

Summary
Given two lines that do not pass through the origin, find the shortest route that starts at the origin, touches both lines, and returns to the origin.
Level

Medium5 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

Maggy got a camera-equipped drone as a present. She wants to take photos of two nearby straight infinite roads using the drone. The best road photos are taken directly above the road. She wants the drone's route to be as short as possible, because she is afraid the batteries might not last long enough. The drone must start and finish at Maggy's house. Help her plan the shortest possible route.

Input

The first line of the input contains three integers a,b,ca, b, c (−106≤a,b,c≤106-10^6 \leq a,b,c \leq 10^6, a≠0a \neq 0 or b≠0b \neq 0), separated by single spaces. They describe the first road, which satisfies the equation ax+by=ca x + b y = c. The second and last line of the input contains a similar description of the second road.

The two roads are different, that is, they do not coincide. Furthermore, they do not pass through Maggy's house, whose coordinates are (0,0)(0,0).

Output

Write a single real number on the first and only line of the output: the smallest possible length of the drone's route. The answer is accepted if its relative or absolute error is at most 10−610^{-6}.

Examples1

  1. Example 1

    Input
    1 0 2
    -1 1 1
    
    Expected output
    5.099019513593