Hide

Problem C
Return of the Jedi

Luke Skywalker races through the forest on a speeder bike, trying to outrun a patrol of Imperial scouts on Endor. A small moon near a new Death Star, Endor is covered by dense foliage and a thick forest of ancient towering trees. The speeder bike, which Luke stole from an Imperial scout, is an antigravity vehicle capable of speeds of 200 miles an hour. How quickly can Luke reach Princess Leia in the Ewok village?

The forest is a plane with T trees. Each tree trunk is a circle. Luke’s position is specified by a pair of coordinates (xluke,yluke) within the plane. The Ewok village has coordinates (xewok,yewok). You are to find the shortest travel time from Luke’s position to the Ewok village.

Input

The first line of input contains five numbers T, xluke, yluke, xewok,yewok. T is a non-negative integer not exceeding 10, the number of trees. Then follow T lines, each giving the coordinates and diameter of a tree: xtreei, ytreei, dtreei. Coordinates and diameters are real numbers in miles with at most one digit after the decimal point. Each coordinate is between 100 and 100 (inclusive), and each diameter is between 0.1 and 200 (inclusive).

Trees do not intersect or touch one another. Luke’s position and the position of the Ewok village do not touch or lie inside any tree.

Output

Output is a single real number, giving the minimum travel time in seconds. The output should be accurate to within an absolute or relative error of at most 106.

Sample Input 1 Sample Output 1
2 0.0 0.0 10.0 0.0
4.0 0.0 1.0
6.0 0.0 1.0
181.126471759
Hide

Please log in to submit a solution to this problem

Log in