結果
| 問題 |
No.306 さいたま2008
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-10-07 09:08:05 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 763 bytes |
| コンパイル時間 | 3,756 ms |
| コンパイル使用メモリ | 74,180 KB |
| 実行使用メモリ | 54,304 KB |
| 最終ジャッジ日時 | 2024-07-20 03:15:52 |
| 合計ジャッジ時間 | 8,790 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
ソースコード
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));
}
}
tenten