A new scheme for exploring a planet surface uses projectiles nicknamed observation bullets instead of rover type explorers. A bullet has no mobile ability of its own, which is what makes it so much cheaper.
A launcher shoots a bullet with an initial velocity. The bullet then flies along a parabola until it touches down. It bounces on the surface and flies along another parabola, and this repeats virtually forever.
We want a bullet to bounce precisely on the target spot of the planet surface, and we set its initial velocity to make that happen. At the instant of that bounce the sensors inside the bullet gather data and send it to the observation base. This may sound like ordinary target shooting, but several issues make it harder.
Write a program that reports the minimum initial speed the mission needs.
Assume the following.
So the bullets fly along a perfect parabolic trajectory.
Assume the following as well.
Here are the basics of rigid body dynamics.
Describe the velocity v of the bullet with its horizontal component vx and its vertical component vy, where positive means upward. The initial velocity has the components vix and viy, so immediately after the launch vx=vix and vy=viy hold. At time t, write the horizontal distance of the bullet from the launcher as x and its altitude as y.
The horizontal velocity component stays constant during the flight when atmospheric resistance is ignored. The horizontal distance from the launcher is therefore proportional to the time elapsed.
x=vixt
The vertical velocity component vy is gradually decelerated by the gravity. With the gravity acceleration g, this differential equation holds during the flight.
dtdvy=−g
Solving it with the initial conditions vy=viy and y=0 at t=0 gives the following.
y=−21gt2+viyt=−(21gt−viy)t
That equation says the bullet reaches the ground again at t=2viy/g. The point of the bounce is thus at distance 2vixviy/g from the launcher. In other words, to make the bullet fly the distance l, the two components of the initial velocity satisfy 2vixviy=lg.
Eliminating the parameter t from the two equations above gives the equation of the parabolic trajectory of the bullet.
y=−2vix2gx2+vixviyx
For ease of computation this problem uses a special unit system, in which the gravity acceleration g of the planet is exactly 1.0.
The input is a single test case in the following format.
d n b
p1 h1
p2 h2
.
.
.
pn hn
The first line contains three integers d, n, and b. Here d is the distance from the launcher to the target spot (1≤d≤10000), n is the number of obstacles (1≤n≤10), and b is the maximum number of bounces allowed (0≤b≤15). The bounce at the target spot is not counted in that number.
Each of the following n lines has two integers. On the k-th line, pk is the position of the k-th obstacle, its distance from the launcher, and hk is its height from the ground level. For k=1,…,n−1, 0<p1 and pk<pk+1 hold, and pn<d. For k=1,…,n, 1≤hk≤10000 holds.
Print the smallest initial speed vi that makes the bullet reach the target. The initial speed of the bullet is defined as follows.
vi=vix2+viy2
Round the value at the sixth digit after the decimal point and print it on one line with exactly five digits after the decimal point.