結果

問題 No.306 さいたま2008
ユーザー tentententen
提出日時 2020-10-07 09:08:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 4,329 ms
コンパイル使用メモリ 71,064 KB
実行使用メモリ 56,608 KB
最終ジャッジ日時 2023-09-27 09:08:31
合計ジャッジ時間 8,711 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,240 KB
testcase_01 AC 135 ms
56,400 KB
testcase_02 AC 130 ms
55,892 KB
testcase_03 AC 132 ms
55,824 KB
testcase_04 AC 134 ms
55,796 KB
testcase_05 AC 134 ms
56,016 KB
testcase_06 AC 137 ms
56,172 KB
testcase_07 AC 134 ms
56,280 KB
testcase_08 AC 135 ms
56,120 KB
testcase_09 AC 134 ms
56,316 KB
testcase_10 AC 135 ms
56,208 KB
testcase_11 AC 133 ms
56,340 KB
testcase_12 AC 133 ms
56,204 KB
testcase_13 AC 139 ms
56,184 KB
testcase_14 AC 129 ms
56,432 KB
testcase_15 AC 132 ms
55,812 KB
testcase_16 AC 134 ms
55,968 KB
testcase_17 AC 134 ms
56,376 KB
testcase_18 AC 134 ms
55,760 KB
testcase_19 AC 138 ms
56,244 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 135 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int xa = sc.nextInt();
		int ya = sc.nextInt();
		int xb = sc.nextInt();
		int yb = sc.nextInt();
		double left = Math.min(ya, yb);
		double right = Math.max(ya, yb);
		for (int i = 0; i < 1000000; i++) {
		    double m1 = (left * 2 + right) / 3;
		    double m2 = (left + right * 2) / 3;
		    if (getDist(xa, ya, xb, yb, m1) <= getDist(xa, ya, xb, yb, m2)) {
		        right = m2;
		    } else {
		        left = m1;
		    }
		}
		System.out.println(right);
	}
	
	static double getDist(int x1, int y1, int x2, int y2, double yy) {
	    return Math.sqrt(x1 * x1 + (y1 - yy) * (y1 - yy)) + Math.sqrt(x2 * x2 + (y2 - yy) * (y2 - yy));
	}
}
0