Imperfect GPS

Given a running path and a recording interval t, compute the percentage of the real distance the GPS receiver loses by sampling positions at fixed times and joining them with straight lines.

Medium5GeometrySimulationImplementationMathInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Many runners carry a GPS receiver to count the distance they cover. A receiver is not perfect. It does not record its position continuously. It only saves the position at fixed moments, so it misses parts of the real path. The receiver in this problem works like this.

  • It saves the starting position at time 0, when the run begins.
  • After that it saves the position every tt units of time.
  • It always saves the position at the final moment of the run, even when the running time is not a multiple of tt.

The receiver treats the path between two consecutively saved positions as a straight line. Because of that, the distance it computes can come out shorter than the distance really covered.

The left half of the table below is a real path. The runner reached each position at the listed time and stopped running at time 11. If the receiver saves a position every 2 units of time, it records the right half.

TimeReal positionTimeSaved position
0(0,0)0(0,0)
3(0,3)2(0,2)
5(-2,5)4(-1,4)
7(0,7)6(-1,6)
9(2,5)8(1,6)
11(0,3)10(1,4)
11(0,3)

The distance really covered is about 14.313708 and the receiver measures about 11.650281. The two differ by about 2.663427, which is about 18.607525% of the real distance.

You are given the positions and times of a running path together with the recording interval tt of the receiver. Compute what percentage of the real distance the receiver loses. The runner moves in a straight line at constant speed between two consecutive positions.

Input

The input holds a single test case. The first line holds two integers nn (2n1002 \le n \le 100) and tt (1t1001 \le t \le 100), where nn is the number of positions on the running path and tt is the interval at which the receiver saves a position, in seconds.

Each of the next nn lines holds three integers. On line ii, the values xix_i, yiy_i (106xi,yi106-10^6 \le x_i, y_i \le 10^6) are the coordinates of the ii-th position on the path, and tit_i (0ti1060 \le t_i \le 10^6) is the time in seconds at which the runner reaches it. The values tit_i are given in increasing order and no value appears twice. The first position is the start of the run and the last one is the end, so t1t_1 is always 0. The total distance of the run is greater than zero.

Output

Print what percentage of the real distance the receiver loses, rounded to four digits after the decimal point. Print exactly four digits after the decimal point, for example 18.6075 or 0.0000.

The distance the receiver measures never exceeds the real distance, so the answer is never negative. When nothing is lost, print 0.0000 and not a negative zero.