QOJ.ac

QOJ

时间限制: 0.5 s 内存限制: 64 MB 总分: 100

#1480. 冯·诺依曼的苍蝇

统计

冯·诺依曼曾被问及以下问题:

两名骑自行车的人 $A$ 和 $B$ 同时从相距 $250$ 英里的地方出发,相向而行。$A$ 的速度为每小时 $10$ 英里,$B$ 的速度为每小时 $15$ 英里。与此同时,一只苍蝇从 $A$ 的自行车前轮出发,以每小时 $20$ 英里的速度飞向 $B$ 的自行车。当它碰到 $B$ 的自行车前轮时,它会掉头飞回。随着两辆自行车相互靠近,它不断地往返飞行,触碰两辆自行车的前轮,直到最后被夹在两车之间。由于苍蝇的飞行速度比任何一名骑车人都快,它进行了无数次往返,但总飞行距离却是有限的(无穷级数收敛)。请问这只苍蝇一共飞行了多少英里?

冯·诺依曼立即(在脑海中)对这个无穷级数求和,并得出了正确答案:$200$ 英里。

你需要编写一个程序来解决该问题的通用版本,即初始距离和速度可以变化。

输入格式

输入的第一行包含一个整数 $P$ ($1 \le P \le 1000$),表示数据集的数量。每个数据集应被独立处理。

每个数据集包含一行,包含五个值:一个整数 $N$(数据集编号),以及四个浮点数值:$D$(两辆自行车之间的初始距离,$10 \le D \le 1000$)、$A$(骑车人 $A$ 的速度,单位为英里每小时,$1 \le A \le 30$)、$B$(骑车人 $B$ 的速度,单位为英里每小时,$1 \le B \le 30$)以及 $F$(苍蝇的速度,单位为英里每小时,$A < F \le 50$)。

输出格式

对于每个数据集,输出一行。内容为数据集编号,后跟一个空格,再跟苍蝇飞行的英里数(即输入值所描述的无穷级数之和),保留两位小数。

样例

样例输入 1

5
1 250 10 15 20
2 10.7 3.5 4.7 5.5
3 523.7 15.3 20.7 33.3
4 1000 30 30 50
5 500 15 15 25

样例输出 1

1 200.00
2 7.18
3 484.42
4 833.33
5 416.67

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.