QOJ.ac

QOJ

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

#8677. Carl の休暇

Statistics

アリの Carl が帰ってきました!曲がりくねった道を進み(2004 年世界大会の問題 A)、八面体の上を歩き回った(2009 年世界大会の問題 C)あとは、少し休暇を取って観光する時間です!そして、たとえばピラミッドのような高い建造物の頂上ほど、景色を見るのによい場所があるでしょうか!!高いピラミッドを見るなら、エジプトほどよい場所があるでしょうか!!!(とてもわくわくします!!!!!)

あるピラミッドの頂上で景色を楽しんだあと、Carl は別のピラミッドの頂上へ行きたいと思っています。アリは強い日差しがあまり得意ではないので、ピラミッドの表面と、それらが置かれている平面だけを歩けるとして、2 つの頂上の間を移動する最短距離を求めたいと考えています。幾何学的には、ピラミッドは正四角錐です。つまり、頂点は正方形の底面の中心の真上にあります。

problem_8677_3813366f844ac8208fc4d993aa17c6f6.png

図 D.1:入力例 1 に対応する 2 つのピラミッド。黒い線は頂点間の最短経路を示しています。

入力

入力の 1 行目には 5 つの整数 $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)$)は最初のピラミッドの 1 辺を定めます。ピラミッドの本体は $(x_1,y_1)$ から $(x_2,y_2)$ への有向ベクトルの左側にあります。$h$($1 \le h \le 10^5$)はピラミッドの高さです。2 行目は同じ形式で 2 番目のピラミッドを記述します。2 つのピラミッドの底面の共通部分の面積は $0$ です。

出力

Carl が 2 つのピラミッドの頂上の間を移動する最短距離を出力してください。解答の絶対誤差または相対誤差は $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.