eolymp
bolt
Try our new interface for solving problems
Məsələlər

Parabolic teleports

Parabolic teleports

Zaman məhdudiyyəti 2 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

Flatland is a plane with a Cartesian coordinate system Oxy. Citizens of Flatland are points that move with the speed1. Consequently, the minimal time it takes for a Flatlander to move from point V to point W is equal to the length of the line segment VW. This fact is taught in the schools of Flatland as the "shortest path theorem".

However, since George Edward Nius invented the devices called parabolic teleports, the theorem no longer holds. A parabolic teleport is a contiguous section of a parabola along which it is possible to move with infinite speed. In other words, it is possible to move from any point on the parabolic teleport to any other point on the same parabolic teleport in zero time.

The points (x, y) that belong to the teleport are given by the formulae y = A—x^2+B—x+C, XLxXR, where A, B, C, XL, XR are the parameters of the teleport.

After inventing the teleports, G.E.Nius founded a company to build them. At the moment, the company has already built N of those devices. One might imagine that they are shoveling money left and right, but…

But in practice, the Flatlanders still think the shortest path theorem is true and nobody has even tried the parabolic teleports. To help the situation, G.E.Nius has hired you to write a program that, given two points V and W, would compute the time it would take to move from V to W using the teleports the company has already built. The idea is that the users of the program will see that the time is less than the length of the segment VW and start to use the invention of Mr. Nius.

Are you up to the task?

Giriş verilənləri

Input data are in the first line of the file is the integer N (0N100), the number of the teleports. On the second line of the file are the integers X_V and Y_V (-100X_V100, -1000000Y_V1000000), the coordinates of the source point V. On the third line of the file are the integers X_W and Y_W (-100X_W100, -1000000Y_W1000000), the coordinates of the destination point W.

Each of the N following lines contains 5 integers, separated by spaces, that describe the ith teleport – giving its parameters A_i, B_i, C_i, X_Li, X_Ri (-100A_i, B_i, C_i100, A_i0, -100X_Li < X_Ri100).

Çıxış verilənləri

Output data should be put to the first and only line of the file should contain one real number, the minimal time it takes to move from point A to point B. The absolute error of the answer must not exceed 10^{-4}.

Nümunə

Giriş verilənləri #1
2
0 10
0 -10
1 0 0 -10 10
-1 0 0 -10 10
Çıxış verilənləri #1
6.2449979984
Mənbə ACM Programming Contest 2005, Minsk, October 2005