Runaway Domino

Time Limit : 3 sec, Memory Limit : 65536 KB

Runaway Domino

``Domino effect'' is a famous play using dominoes. A player sets up a chain of dominoes stood. After a chain is formed, the player topples one end of the dominoes. The first domino topples the second domino, the second topples the third and so on.

You are playing domino effect. Before you finish to set up a chain of domino, a domino block started to topple, unfortunately. You have to stop the toppling as soon as possible.

The domino chain forms a polygonal line on a two-dimensional coordinate system without self intersections. The toppling starts from a certain point on the domino chain and continues toward the both end of the chain. If the toppling starts on an end of the chain, the toppling continue toward the other end. The toppling of a direction stops when you touch the toppling point or the toppling reaches an end of the domino chain.

You can assume that:

  • You are a point without volume on the two-dimensional coordinate system.
  • The toppling stops soon after touching the toppling point.
  • You can step over the domino chain without toppling it.

You will given the form of the domino chain, the starting point of the toppling, your coordinates when the toppling started, the toppling velocity and the your velocity. You are task is to write a program that calculates your optimal move to stop the toppling at the earliest timing and calculates the minimum time to stop the toppling.


The first line contains one integer N, which denotes the number of vertices in the polygonal line of the domino chain (2 \leq N \leq 1000). Then N lines follow, each consists of two integers x_{i} and y_{i}, which denote the coordinates of the i-th vertex (-10,000 \leq x, y \leq 10000). The next line consists of three integers x_{t}, y_{t} and v_{t}, which denote the coordinates of the starting point and the velocity of the toppling. The last line consists of three integers x_{p}, y_{p} and v_{p}, which denotes the coordinates of you when the toppling started and the velocity (1 \leq v_{t} \lt v_{p} \leq 10). You may assume that the starting point of the toppling lies on the polygonal line.


Print the minimum time to stop the toppling. The output must have a relative or absolute error less than 10^{-6}.

Sample Input 1

0 0
15 0
5 0 1
10 10 2

Output for the Sample Input 1


Sample Input 2

-10 0
0 0
0 10
-1 0 1
3 0 2

Output for the Sample Input 2


Sample Input 3

0 0
10 0
5 0 1
9 0 3 

Output for the Sample Input 3


Source: ACM-ICPC Japan Alumni Group Winter Contest 2012 , Tokyo, Japan, 2012-03-10