QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#1937. 原子赛车

统计

2020 年,一场原子能赛车比赛即将举行。与当今的赛车比赛不同,车队无需担心燃料问题。赛车可以在整个赛程中行驶而无需加油。相反,关键因素是轮胎。车队需要仔细规划在何处更换轮胎。

比赛是一场在赛道上设有 $n$ 个检查点的公路赛。它们距离起点的距离分别为 $a_1, a_2, \dots, a_n$(单位:千米)。第 $n$ 个检查点即为终点。在第 $i$ 个检查点($i < n$),可以更换赛车轮胎。当然,车队可以选择在每个检查点是否更换轮胎。更换轮胎需要 $b$ 秒(包括制动和加速的额外时间)。如果车队选择不更换轮胎,则在检查点不会损失时间。

更换轮胎后,由于轮胎温度低于设计的最佳温度,赛车在一段时间内无法高速行驶。另一方面,在长时间不更换轮胎行驶后,由于磨损的轮胎无法很好地抓地,赛车也无法高速行驶。行驶从 $x$ 到 $x+1$ 的一千米路段所需的时间(单位:秒)由以下表达式给出。这里 $x$ 是一个非负整数,表示从最近一次更换轮胎(或起点)算起的距离(单位:千米)。$r, v, e$ 和 $f$ 是给定的常数。

$$ \begin{aligned} &1/(v - e \times (x - r)) && (\text{如果 } x \ge r) \\ &1/(v - f \times (r - x)) && (\text{如果 } x < r) \end{aligned} $$

你的任务是编写一个程序,确定使到达终点的总时间最小化的最佳换胎策略。

输入格式

输入包含多个数据集,每个数据集对应一种比赛情况。数据集的格式如下:

$n$ $a_1 \ a_2 \ \dots \ a_n$ $b$ $r \ v \ e \ f$

输入项的含义在题目描述中给出。如果一行包含两个或多个输入项,它们之间用空格分隔。

$n$ 是不超过 100 的正整数。每个 $a_1, a_2, \dots, a_n$ 都是满足 $0 < a_1 < a_2 < \dots < a_n \le 10000$ 的正整数。$b$ 是不超过 $100.0$ 的正小数。$r$ 是满足 $0 \le r \le a_n - 1$ 的非负整数。$v, e$ 和 $f$ 均为正小数。 你可以假设 $v - e \times (a_n - 1 - r) \ge 0.01$ 且 $v - f \times r \ge 0.01$。

输入的结尾由一行单个零表示。

输出格式

对于输入中的每个数据集,输出一行包含一个小数。该小数应给出采取最佳策略时到达终点所经过的时间(单位:秒)。输出行不应包含多余的字符(如空格)。

答案的误差不应超过 $0.001$。只要满足上述精度条件,你可以输出小数点后任意位数的数字。

样例

样例输入 1

2
2 3
1.0
1 1.0 0.1 0.3
5
5 10 15 20 25
0.15
1 1.0 0.04 0.5
10
1783 3640 3991 4623 5465 5481 6369 6533 6865 8425
4.172
72 59.4705 0.0052834 0.0611224
0

样例输出 1

3.5397
31.9249
168.6682

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.