We are given: signature polyline A1 A2 ... An. Each segment is drawn at constant speed 50 mm/s. For one signature, the time taken is total length of polyline (sum of distances between consecutive points) divided by 50. Then we have k signatures. So total time = k * (total length / 50). But careful: The problem says: "Scrooge signed exactly k papers throughout his life and all those signatures look the same." That seems to imply that he signed k times, each signature is the same polyline. So total time = k * (length) / 50.
However, sample inputs:
Example 1: n=2, points (0,0) and (10,0). Distance = 10 mm. Speed 50 mm/s => time per signature = 10/50 = 0.2 seconds. k=1 => total = 0.2. Output matches.
Example 2: n=5, k=10. Compute total length? Let's test: Points: (3,1), (-5,6), (-2,-1), (3,2), (10,0). Compute distances: d12 = sqrt(( -5-3)^2 + (6-1)^2) = sqrt((-8)^2 + 5^2) = sqrt(64+25)= sqrt(89) ≈9.433981; d23 = sqrt((-2 - (-5))^2 + (-1-6)^2) = sqrt((3)^2 + (-7)^2)= sqrt(9+49)= sqrt(58)≈7.615773; d34 = sqrt((3-(-2))^2 + (2-(-1))^2)= sqrt(5^2+3^2)= sqrt(25+9)= sqrt(34)≈5.830952; d45 = sqrt((10-3)^2 + (0-2)^2)= sqrt(7^2+(-2)^2)= sqrt(49+4)= sqrt(53)≈7.280110; sum ≈ 9.433981+7.615773+5.830952+7.280110 ≈ 30.160816. Multiply by k=10 => total length drawn = 301.60816 mm. Divide by 50 = 6.0321632 seconds. Output matches (6.032163204). So indeed total time = k * total_length / 50.
Example 3: n=6, k=10, points: (5,0), (4,0), (6,0), (3,0), (7,0), (2,0). These are all on x-axis. Distances: 5->4 =1, 4->6 =2, 6->3 =3, 3->7 =4, 7->2 =5. Sum = 1+2+3+4+5 =15. k=10 => total length =150 mm. /50 =3.0 seconds. Output matches.
Thus problem is straightforward: compute sum of Euclidean distances between consecutive points, multiply by k, divide by 50. Output with sufficient precision.
Constraints: n up to 100, k up to 1000, coordinates up to 20, so distances at most sqrt( (40)^2+(40)^2 ) ~ 56.57 per segment, sum <= about 100*56 = 5600, times k <=1000 => total length <= 5.6e6, time <= 112000 seconds, fits in double.
Implementation: read n,k, then loop n times read xi,yi store in arrays or just keep previous point. Compute total = 0. For i from 2 to n: add distance between point i-1 and point i. Then time = total * k / 50. Print with appropriate precision (like printf("%.9lf", time)).
Edge cases: n=2 minimal; k=1; all good.
Thus solution is trivial.
But wait: The problem statement includes "The resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style." That suggests that the total length is simply the sum of segment lengths, regardless of intersections; we are already doing that.
So answer: total_time = k * (sum_{i=1}^{n-1} distance(A_i, A_{i+1})) / 50.0.
Now, let's produce final answer. We'll write a solution in C++.
Implementation steps:
- Read integers n, k.
- Initialize double total = 0.0.
- Read first point x_prev, y_prev.
- For i = 2 to n: read x, y; compute dx = x - x_prev, dy = y - y_prev; total += sqrt(dxdx + dydy); set prev = current.
- double time = total * k / 50.0;
- Print with high precision: cout << fixed << setprecision(9) << time << endl; or printf.
Now, just output.
But we have to ensure the error tolerance: relative/absolute <= 1e-6. So 9 decimal digits is fine.
Thus final answer.
But maybe there's a twist: Could it be that the signature polyline is given with points and Scrooge signs it exactly as given, but the speed is constant 50 mm/s; total time as above.
Yes.
So final answer: write code.
Wait, sample 3: points: (5,0) (4,0) (6,0) (3,0) (7,0) (2,0). The distances are: |5-4|=1, |4-6|=2, |6-3|=3, |3-7|=4, |7-2|=5. Sum=15. That matches.
Alright.
Now produce final response. ```cpp
#include
#include
#include
using namespace std;
int main() {
int n, k;
cin >> n >> k;
double total_length = 0.0;
// read first point
double x_prev, y_prev;
cin >> x_prev >> y_prev;
for (int i = 1; i < n; ++i) {
double x, y;
cin >> x >> y;
double dx = x - x_prev;
double dy = y - y_prev;
total_length += sqrt(dx*dx + dy*dy);
x_prev = x;
y_prev = y;
}
double total_time = total_length * k / 50.0;
// print with required precision
cout << fixed << setprecision(9) << total_time << endl;
return 0;
}