PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000456. Mèo và chuột (Cat and Mice)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Mèo và chuột (Cat and Mice)

Cat and Mice

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A cat starts at the origin (0,0)(0,0) of a plane. Mouse ii stays at (xi,yi)(x_i,y_i) and can be caught at any time from 00 through sis_i seconds, inclusive.

Starting at time zero with speed vv, the cat runs directly to a chosen mouse, catches it without spending any extra time, and proceeds to the next one. After each catch, its current speed is multiplied by mm. Arriving exactly at the deadline sis_i is permitted; arriving later is not.

Choose the order of catching all nn mice to minimize the required starting speed, measured in distance units per second.

Input

The first line contains an integer nn.

Each of the next nn lines contains three integers xi,yi,six_i,y_i,s_i.

The final line gives the real number mm with exactly two digits after the decimal point.

Output

Print the minimum initial speed. An absolute or relative error of at most 10−310^{-3} is permitted.

Subtasks

  • Subtask 1 (20 points): 1≤n≤71\le n\le 7; 1≤i≤n1\le i\le n; −1000≤xi,yi≤1000-1000\le x_i,y_i\le1000; 1≤si≤100001\le s_i\le10000; 0.75≤m≤0.990.75\le m\le0.99; all positions (xi,yi)(x_i,y_i) are distinct and different from (0,0)(0,0); mm is given to two decimal places.
  • Subtask 2 (30 points): 1≤n≤111\le n\le 11; 1≤i≤n1\le i\le n; −1000≤xi,yi≤1000-1000\le x_i,y_i\le1000; 1≤si≤100001\le s_i\le10000; 0.75≤m≤0.990.75\le m\le0.99; all positions (xi,yi)(x_i,y_i) are distinct and different from (0,0)(0,0); mm is given to two decimal places.
  • Subtask 3 (50 points): 1≤n≤151\le n\le 15; 1≤i≤n1\le i\le n; −1000≤xi,yi≤1000-1000\le x_i,y_i\le1000; 1≤si≤100001\le s_i\le10000; 0.75≤m≤0.990.75\le m\le0.99; all positions (xi,yi)(x_i,y_i) are distinct and different from (0,0)(0,0); mm is given to two decimal places.

Examples

Input 1

1
3 4 2
.75

Output 1

2.4999999987500003

Explanation 1

The distance is 5 and the deadline is 2, so the exact optimum is 5/2=2.55/2=2.5.

Input 2

2
0 100 10
0 -100 100
.80

Output 2

9.999999999000002

Explanation 2

Catch mouse 1 first. Speed 10 reaches it at time 10, and the remaining 200 units at speed 8 take 25 seconds. The total 35 meets the second deadline. Any route to mouse 1 has length at least 100, making speed below 10 impossible.

Input 3

2
0 100 10
0 -100 15
.80

Output 3

23.33333333177778

Explanation 3

Order 1 then 2 requires 350/v≤15350/v\le15 and 100/v≤10100/v\le10. Reversing the order requires 350/v≤10350/v\le10. Thus the optimum is 70/3≈23.3333333370/3\approx23.33333333.