QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 2048 MB Puntuación total: 100

#2935. 蜘蛛与苍蝇

Estadísticas

在 1903 年 6 月 14 日的英国报纸《每周快讯》(Weekly Dispatch)上,Henry Dudeny 提出了以下问题(没错,现在每个人都在 Google 上搜索“henry dudeny spider fly”)。

在一个宽 12 英尺、高 12 英尺、长 30 英尺的房间里,有一只蜘蛛位于一端墙壁上,距离天花板 1 英尺,且水平居中。有一只苍蝇位于对面墙壁上,距离地面 1 英尺,且水平居中。蜘蛛沿墙壁、天花板或地板爬行到达苍蝇处的最短路径(以英尺为单位)是多少?

下图展示了几条可能的路径及其长度。40 英尺的路径是(其中一条)最短路径。

编写一个程序来解决通用的蜘蛛与苍蝇问题。

输入格式

输入使用一个以房间角落为原点的坐标系。$x$ 轴指向宽度方向,$y$ 轴指向高度方向,$z$ 轴指向长度方向,使得 $0 \le x \le \text{Width}$,$0 \le y \le \text{Height}$ 且 $0 \le z \le \text{Length}$:

输入包含三行。第一行包含三个双精度浮点数,依次给出房间的 $\text{Width}$、$\text{Height}$ 和 $\text{Length}$(单位为英尺,且 $0 < \text{Width}, \text{Height}, \text{Length} \le 30$)。第二行包含三个双精度浮点数:$x, y, z$,依次给出蜘蛛的坐标。第三行包含三个双精度浮点数:$x, y, z$,依次给出苍蝇的坐标。在后两行中,点均位于墙壁、地板或天花板上,即满足 $x = 0$ 或 $x = \text{Width}$ 或 $y = 0$ 或 $y = \text{Height}$ 或 $z = 0$ 或 $z = \text{Length}$。

输出格式

输出一行,包含一个浮点数值,精确到小数点后三位,表示最短路径的长度(单位为英尺)。

样例

输入格式 1

12 12 30
6 11 0
6 1 30

输出格式 1

40.000

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.