QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100

#9861. 山静而孤

统计

Peng 是一位年轻的登山者,非常热爱登山。一天,他独自攀登一座高山时,不幸滑倒了。他开始翻滚,沿着山坡滚落。

这座山(直到 Peng 所在的位置)是一个单调斜坡,由 $n$ 个点 $(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)$ 描述,满足 $0 < x_1 < x_2 < \dots < x_n < 1000$ 且 $0 < y_1 < y_2 < \dots < y_n < 1000$。斜坡包含以下线段:$((-\infty, 0), (0, 0))$,$((0, 0), (x_1, y_1))$,以及对于所有 $1 \le i \le n-1$ 的 $((x_i, y_i), (x_{i+1}, y_{i+1}))$。为简化起见,我们将 Peng 看作一条长度为 1 的线段 $((x_n, y_n), (x_n, y_n + 1))$,并将 $(x_n, y_n + 1)$ 端点称为 Peng 的“头”。

现在我们描述翻滚过程。Peng 总是绕着他与山坡的最低接触点进行逆时针(下坡方向)旋转。每当他有了新的(更低的)接触点时,他就从该点开始旋转。只有当他的“头”的 $y$ 坐标为 0 时,他才会停止翻滚。

Peng 想知道在整个翻滚过程中,他的“头”总共移动了多少距离。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 1000$)。

接下来的 $n$ 行中,第 $i$ 行包含两个实数 $x_i$ 和 $y_i$,精度最多为 6 位小数。

输出格式

输出一个实数,表示总距离。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。形式化地说,设你的答案为 $a$,标准答案为 $b$,若满足 $\frac{|a-b|}{\max(1, |b|)} \le 10^{-6}$,则你的答案被视为正确。

样例

样例输入 1

1
0.5 0.5

样例输出 1

2.094395102393195

样例输入 2

2
0.2 0.8
1 1

样例输出 2

4.465554239614399

说明

保证在旋转过程中,当线段的端点与山坡接触时,该点与点 $(0, 0), (x_1, y_1), \dots, (x_{n-1}, y_{n-1})$ 的距离不小于 0.0001。

样例解释。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.