#C9083. Vehicle Total Distance Calculation
Vehicle Total Distance Calculation
Vehicle Total Distance Calculation
You are given the travel paths of multiple vehicles. Each vehicle's path is represented by a sequence of coordinates in the 2D plane. Your task is to calculate the total distance traveled by each vehicle.
The distance between two points \((x_1, y_1)\) and \((x_2, y_2)\) is defined by the Euclidean distance formula: $$d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$$ For a given vehicle, sum the distances between consecutive points and round the result to the nearest integer.
For example, the distance between points (0,0) and (3,4) is 5, and the total distance for a vehicle with locations [(0,0), (3,4), (6,8)] is 10.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer
T
representing the number of vehicles. - For each vehicle, the first line contains an integer
P
indicating the number of points. - Then follow
P
lines, each containing two floating-point numbers representing the x and y coordinates of a point.
outputFormat
For each vehicle, print a single integer on a separate line to stdout representing the total distance traveled (rounded to the nearest integer).
## sample2
3
0.0 0.0
3.0 4.0
6.0 8.0
2
2.0 3.0
5.0 7.0
10
5
</p>