Drone With a Camera
Time limit1sMemory limit256 MB
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.
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 (, or ), separated by single spaces. They describe the first road, which satisfies the equation . 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 .
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 .