This page is still under construction.

Parts of this page are still being built. What you see may change.

Cat and Mice

Time limit2sMemory limit512 MB

Summary
Find the smallest initial speed v so the cat can visit all points in some order, each arrival at or before its deadline, with speed multiplied by m after every meal.
Level

Hard8 of 10

Topics
Binary search, Dynamic programming, Bit manipulation, Geometry
Solved
No attempts yet

Problem

A cat lives on the Cartesian plane and her home is at (0,0)(0, 0). No mouse lives at that point.

At time t=0t = 0, nn mice stick their heads above the ground at distinct points, and the cat sees every one of them. Mouse ii stays above ground at its point until time sis_i, then ducks underground where the cat cannot reach it.

The cat plans to eat every mouse. At time t=0t = 0 she leaves (0,0)(0, 0) with initial speed vv and runs in a straight line toward one of the mice. She eats it the instant she arrives, then runs in a straight line toward another mouse, and she repeats this until no mouse is left. Eating takes no time.

Every meal slows her down: her speed is multiplied by the constant mm each time she eats a mouse, so after eating kk mice she moves at speed vmkv m^k.

The cat eats mouse ii only if she reaches its point at time sis_i or earlier. Arriving exactly at time sis_i still counts.

The cat picks the order that suits her best. Find the smallest initial speed vv for which some order lets her eat all nn mice.

Input

The first line contains an integer nn (1≤n≤151 \le n \le 15), the number of mice.

Each of the next nn lines contains three integers xx, yy, and ss (−1000≤x,y≤1000-1000 \le x, y \le 1000, 1≤s≤100001 \le s \le 10000), meaning that a mouse sits at (x,y)(x, y) and ducks underground at time t=st = s. No two mice share a point, and no mouse is at (0,0)(0, 0).

The last line contains mm (0.75≤m≤0.990.75 \le m \le 0.99), a decimal number with one or two digits after the decimal point. It may be written without the leading zero, as in .75.

Output

Print the minimum initial speed, in units of distance per second, that lets the cat eat every mouse. Round it to six digits after the decimal point and print exactly six of them.

Examples3

  1. Example 1

    Input
    1
    3 4 2
    .75
    
    Expected output
    2.500000
    
  2. Example 2

    Input
    2
    0 100 10
    0 -100 100
    .80
    
    Expected output
    10.000000
    
  3. Example 3

    Input
    2
    0 100 10
    0 -100 15
    .80
    
    Expected output
    23.333333