QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#8677. Carl 的假期

Statistics

螞蟻 Carl 又回來了!在走過蜿蜒的小徑(2004 年世界總決賽 A 題)和漫遊八面體(2009 年世界總決賽 C 題)之後,是時候休個小假——去觀光了!還有哪裡比高聳建築物的頂端,例如金字塔,更適合觀光呢!!而要看高大的金字塔,還有哪裡比埃及更好呢!!!(真是太令人興奮了!!!!!)

在一座金字塔的頂端飽覽景色之後,Carl 想前往另一座金字塔的頂端。螞蟻不太能忍受烈日,因此他想找出這兩座金字塔頂端之間的最短行走距離,假設他只能在金字塔的表面及金字塔所在的平面上行走。從幾何上來說,這些金字塔都是正四角錐,也就是說,頂點位於正方形底面的中心正上方。

problem_8677_3813366f844ac8208fc4d993aa17c6f6.png

圖 D.1:對應範例輸入 1 的兩座金字塔示意圖。黑線表示兩個頂點之間的最短路徑。

輸入格式

輸入第一行包含五個整數 $x_1,y_1,x_2,y_2,h$,其中 $x_1,y_1,x_2,y_2$($-10^5 \le x_1,x_2,y_1,y_2 \le 10^5$ 且 $(x_1,y_1) \ne (x_2,y_2)$)定義第一座金字塔的一條邊,金字塔的主體位於從 $(x_1,y_1)$ 指向 $(x_2,y_2)$ 的有向向量左側,而 $h$($1 \le h \le 10^5$)是金字塔的高度。輸入第二行以相同格式描述第二座金字塔。兩座金字塔底面的交集面積為 $0$。

輸出格式

輸出 Carl 在兩座金字塔頂端之間行走的最短距離。答案的絕對誤差或相對誤差不得超過 $10^{-6}$。

範例

輸入格式 1

0 0 10 0 4
9 18 34 26 42

輸出格式 1

60.866649532

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.