atcoder#ABC274E. [ABC274E] Booster
[ABC274E] Booster
Score : points
Problem Statement
In a two-dimensional plane, there are towns and chests. Town is at the coordinates , and chest is at the coordinates .
Takahashi will go on a trip where he starts at the origin, visits all towns, and then returns to the origin. It is not mandatory to visit chests, but each chest contains an accelerator. Each time he picks up an accelerator, his moving speed gets multiplied by .
Takahashi's initial moving speed is . Find the shortest time needed to complete the trip.
Constraints
- , , and are distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer. Your output will be considered correct if the absolute or relative error from the judge's answer is at most .
2 1
1 1
0 1
1 0
2.5000000000
Here is one optimal way to complete the trip.
- Go the distance from the origin to chest at a speed of , taking a time of .
- Go the distance from chest to town at a speed of , taking a time of .
- Go the distance from town to town at a speed of , taking a time of .
- Go the distance from town to the origin at a speed of , taking a time of .
2 1
1 1
0 1
100 0
3.4142135624
Here is one optimal way to complete the trip.
- Go the distance from the origin to town at a speed of , taking a time of .
- Go the distance from town to town at a speed of , taking a time of .
- Go the distance from town to the origin at a speed of , taking a time of .
1 2
4 4
1 0
0 1
4.3713203436
Here is one optimal way to complete the trip.
- Go the distance from the origin to chest at a speed of , taking a time of .
- Go the distance from chest to chest at a speed of , taking a time of .
- Go the distance from chest to town at a speed of , taking a time of .
- Go the distance from town to the origin at a speed of , taking a time of .