#P8610. [蓝桥杯 2013 国 A] 车轮轴迹
[蓝桥杯 2013 国 A] 车轮轴迹
Problem Description
Dongdong rides his bicycle home every day along a long and narrow tree-lined path. Because the road has been poorly maintained for many years, it has become very uneven. Although Dongdong bumps a lot each time, he still treats riding through the path as a kind of fun.
Because of the bumps, the route Dongdong takes home is a curve that goes up and down. Dongdong wants to know: how long is this curve exactly? More precisely, Dongdong wants to know the length of the path traveled by the axle (the center of the circle) of his bicycle’s front wheel from the start of the path to the end of the path.
Dongdong measured the road surface. He simplified the road into straight line segments of different lengths. These segments are connected end to end and lie in the same plane. He also built a Cartesian coordinate system in this plane and computed the coordinates of all segment endpoints.
Assume that during the ride, the front wheel always moves forward while staying in contact with the road surface.

Figure shows a simple example of a road surface, where the blue solid line is the road surface and the red dashed line is the path traveled by the wheel axle. In this example, the front wheel axle starts from point , moves horizontally to point , then goes around point on the ground to point (forming a circular arc), then goes downhill along a straight line to point , and finally moves horizontally to point . In this figure, the ground coordinates in order are: . The front wheel radius is . The distances traveled by the front wheel axle are:
; arc length ; ; .
The total length is .

Figure shows a more complex example of a road surface. In this example, the wheel starts going uphill (at point ) before finishing the first downhill. Then at the peak of the slope, it needs to go around a larger circular arc from to . In this figure, the front wheel radius is . The length of each part is:
; arc length ; ; ; arc length ; ; .
The total length is .
Now you are given the wheel radius and the description of the road surface. Please compute the total length of the wheel axle trajectory.
Input Format
The first line contains an integer and a real number , separated by a space, representing the number of coordinate points describing the road surface and the radius of the wheel.
The next lines each contain two real numbers. In the -th line, the two real numbers represent the coordinates of the -th point describing the road surface.
The road surface is defined as the polyline formed by connecting all the given road surface points in order. The given road surface always satisfies the following properties:
- The first coordinate point is always .
- The -coordinates of the first point and the second point are the same.
- The -coordinates of the last point and the second-to-last point are the same.
- The distance between the first point and the second point is at least the wheel radius.
- The distance between the last point and the second-to-last point is at least the wheel radius.
- The -coordinate of each subsequent point is greater than that of the previous point, i.e., for all , .
Output Format
Output a real number, rounded to two decimal places, representing the total length traveled by the wheel axle.
Your result must be exactly the same as the reference answer to get points. The testdata guarantees that the third digit after the decimal point of the exact value is not or .
4 1.50
0.00 0.00
2.00 0.00
4.00 -1.00
6.00 -1.00
6.22
6 1.00
0.00 0.00
3.00 0.00
5.00 -3.00
6.00 2.00
7.00 -1.00
10.00 -1.00
15.20
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , , , .
Time limit: 1 second, 64 MB. Lanqiao Cup 2013, the 4th National Finals.
Translated by ChatGPT 5