Prime Cut 5
View as PDFKirby has to set up a space station to survey a set of stars, each of which has a distinct position
. To set up a space station, Kirby must choose a position on a cut in spacetime.
This cut is a line segment that begins at position
and ends at
, meaning that kirby can choose any position on the x axis between
and
for his space station.
The space station will send out a light beam to each star sequentially, starting with star , then
, ... until it sends a signal to star
.
When the station sends out a signal to a star
, it takes
seconds to reach the star, where
is the distance to the star from the space station.
the signal then takes
seconds to travel back to the space station. Only then can the station send a signal to star
.
The amount of time taken to send and receive a signal from every star is a period, and can be expressed as .
Kirby wants to maximise the number of signals sent to stars, so he wants to choose a position for his station such that the period is small as possible.
What is the smallest period that can be achieved?
hint: functions of the form are monotonically increasing.
Input
The first line has 3 integers , the number of stars, and the start and end points of the cut in spacetime.
lines follow, each with
, the coordinates of a star
.
All points are distinct and guaranteed to not be all collinear.
Output
Write 2 integers, the smallest possible period that occurs when kirby chooses the optimal location for a space station and the x-value of the position for which this occurs. Answers with a relative or absolute error less than 1e-6 will be accepted.
Sample Input
Input 1
2 -1000 1000
1 1
2 2
Output 1
6.32455532
Input 2
1 -2000 1000
5 5
Output 2
10
Input 3
7 -10 0
8 3
10 1
0 2
0 8
7 2
0 0
5 10
Output 3
94.10865829
Comments