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 MBMany 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.
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.
| Time | Real position | Time | Saved 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 t 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.
The input holds a single test case. The first line holds two integers n (2≤n≤100) and t (1≤t≤100), where n is the number of positions on the running path and t is the interval at which the receiver saves a position, in seconds.
Each of the next n lines holds three integers. On line i, the values xi, yi (−106≤xi,yi≤106) are the coordinates of the i-th position on the path, and ti (0≤ti≤106) is the time in seconds at which the runner reaches it. The values ti 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 t1 is always 0. The total distance of the run is greater than zero.
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.