QOJ.ac

QOJ

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

#3417. 运河

Estadísticas

G - Grachten

该死!我不仅睡过了头(今天可是比赛日!),而且在从酒店前往比赛场地的路上被困在了代尔夫特(Delft)的某个地方。我周围到处都是“grachten”,即荷兰许多城市中常见的城市运河。我有点着急,因为 NWERC 比赛几分钟后就要开始了。

更糟糕的是,由于城里正在举行自行车赛,代尔夫特的一些桥梁被关闭了。因此,我决定跳过一些运河,而不是去寻找开放的桥梁。

众所周知,像我这样的计算机科学家擅长算法,但不太擅长运动。此外,我胆子比较小,不想弄湿身体。所以我需要你的帮助来计算我跳过运河所需的距离。

幸运的是,我昨天参加了代尔夫特市中心的游览,了解到代尔夫特所有的铺路石都是正方形且大小相同。这样,我就可以在运河我这一侧进行一些测量(我的单位是铺路石):

图 1 – 第一个样例输入的示意图。

我通过点 $A$ 和 $B$ 从点 $C$ 走到点 $D$,同时数了铺路石的数量。

点 $A$ 和 $C$ 始终位于运河的边缘。点 $B$ 和 $D$ 到运河的距离相同。目标点 $T$ 始终位于运河另一侧的边缘;它是经过 $B$ 和 $A$ 的直线与经过 $D$ 和 $C$ 的直线的交点。$AT$ 和 $AC$ 之间的夹角为 90 度,且运河的两条边缘是平行线。

请帮我计算 $A$ 和 $T$ 之间的距离(即必要的跳跃距离)。

输入格式

对于每个测试用例,输入包含一行,其中包含三个正整数,分别指定了 $A$ 与 $B$、 $A$ 与 $C$ 以及 $B$ 与 $D$ 之间的距离。

你可以放心地假设没有任何距离超过 1000,且 $B$ 与 $D$ 之间的距离大于 $A$ 与 $C$ 之间的距离。

输出格式

对于每个测试用例,输出一行:以最简分数形式(即约去分子和分母的所有公因数)表示 $A$ 和 $T$ 之间的距离。

样例

输入 1

5 3 7
5 3 8
1 2 3
23 42 47
500 500 1000
1 1 1000

输出 1

15/4
3/1
2/1
966/5
500/1
1/999

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.