题号:NC236487
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld
题目描述
"Slipped, tumbled, Mountain is quiet and alone." is a haiku by Santōka Taneda (1882-1940).
Peng is a young climber who enjoys mountaineering really much. One day he was climbing a tall mountain alone when he, unfortunately, slipped. He started tumbling, rolling down the mountain.
The mountain (up to the point where Peng is at) is a monotone slope described by

points
%2C(x_2%2Cy_2)%2C%5Cldots%2C(x_n%2Cy_n))
such that

and

. The slope contains the following segments:
%2C(0%2C0)))
,
%2C(x_1%2Cy_1)))
, and
%2C(x_%7Bi%2B1%7D%2Cy_%7Bi%2B1%7D)))
for all

. For simplicity we consider Peng to be a segment
%2C(x_n%2Cy_n%2B1)))
of length

, and we call the
)
end of the segment Peng's "head".
We now describe the rolling process. Peng always rotates counter-clockwise (downhill) around his lowest contact point with the hill. Whenever he has a new (lower) contact point with the hill, he starts rolling from that point. He only stops rolling when his
"head" has

-coordinate

.
Peng would like to know the total length his
"head" travels in the rolling process.
输入描述:
The first line contains an integer
(
).
For each of the following
lines, the
-th line contains two real numbers
and
with at most
digits of precision.
输出描述:
Output one real number, the total distance.
Your answer will be considered correct if its absolute or relative error does not exceed
. Formally let your answer be
and jury's answer be
. Your answer will be considered correct if
.
备注:
It is guaranteed that during the rotation, when an end point of the segment is in contact with the hill, the point is not within
distance of points
.