当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3227:Mountains

题目描述
Octopus and Penguin love sports, especially the climb. They step on the most top building of Changsha to view the Yuelu Mountain in weekend and are attracted by the imposing landscape. However, they can't see the whole mountain because the building is not high enough. Please help them to calculate the total length of surface for mountain they can see.
Suppose Octopus and Penguin's coordinate is (0,h) and the mountain is composed by n points which satisfy:
1. All points' coordinates are equal to or larger than zero.
2. The first point is 0, it's coordinate is (w0, 0)(w0 >= 0).
3. n points are listing in ascending sort by x-axis.
4. Odd points' y-axis is larger than the former one.
5. Even points' y-axis (except for 0 point) is small than the former one.
Condition 3,4 and 5 is means for three nearby points (w2k, h2k), (w2k+1, h2k+1) and (w2k+2, h2k+2)(k N*,2k+2<n), satisfied w2k < w2k+1 < w2k+2, h2k+1 > h2k and h2k+2 < h2k+1.
6. The last point is (wn-1, 0).

The figure below corresponding sample input one:
输入解释
There are several test cases. For each case, the first line is two integers n (0<n<=1000) and h. Then n lines follow and each line is two integers x and y(0<=x,y<=1000) describe the coordinates of mountains. n=h=0 means end of the input.
输出解释
For each case, output the surface length of mountain they can see.
输入样例
3 5
0 0
1 1
2 0
5 5
0 0
2 2
3 1
5 3
8 0
5 4
0 0
2 2
3 1
5 3
8 0
0 0
输出样例
2.83
7.07
5.66

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3227

最后修改于 2020-10-29T06:56:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536