結果

問題 No.306 さいたま2008
ユーザー hama_duhama_du
提出日時 2015-11-27 22:49:25
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 11,694 ms
コンパイル使用メモリ 236,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 03:38:12
合計ジャッジ時間 11,705 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main
import (
	"fmt"
	"math"
)

func main()  {
	ax, ay, bx, by := 0.0, 0.0, 0.0, 0.0
	fmt.Scan(&ax, &ay, &bx, &by)

	left := min(ay, by)
	right := max(ay, by)

	for i := 0 ; i < 500 ; i++ {
		m1 := (left * 2.0 + right) / 3.0
		m2 := (left + right * 2.0) / 3.0

		c1 := compute(m1, ax, ay, bx, by)
		c2 := compute(m2, ax, ay, bx, by)
		if c1 < c2 {
			right = m2
		} else {
			left = m1
		}
	}
	fmt.Printf("%.9f\n", (left+right)/2)

}

func compute(my, ax, ay, bx, by float64) float64 {
	return math.Sqrt(ax*ax+(ay-my)*(ay-my)) + math.Sqrt(bx*bx+(by-my)*(by-my))
}

func max(a, b float64) float64 {
	if a < b  {
		return b
	} else {
		return a
	}
}

func min(a, b float64) float64 {
	if a > b  {
		return b
	} else {
		return a
	}
}
0