結果

問題 No.306 さいたま2008
ユーザー tentententen
提出日時 2022-07-30 09:53:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 4,070 ms
コンパイル使用メモリ 73,572 KB
実行使用メモリ 50,948 KB
最終ジャッジ日時 2023-09-27 11:23:33
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
50,948 KB
testcase_01 AC 77 ms
50,452 KB
testcase_02 AC 78 ms
50,832 KB
testcase_03 AC 79 ms
50,372 KB
testcase_04 AC 81 ms
50,584 KB
testcase_05 AC 78 ms
50,576 KB
testcase_06 AC 78 ms
48,840 KB
testcase_07 AC 79 ms
50,892 KB
testcase_08 AC 79 ms
50,676 KB
testcase_09 AC 79 ms
50,672 KB
testcase_10 AC 79 ms
50,464 KB
testcase_11 AC 80 ms
50,348 KB
testcase_12 AC 79 ms
50,776 KB
testcase_13 AC 78 ms
48,832 KB
testcase_14 AC 78 ms
50,660 KB
testcase_15 AC 77 ms
50,568 KB
testcase_16 AC 78 ms
50,492 KB
testcase_17 AC 79 ms
50,660 KB
testcase_18 AC 80 ms
50,596 KB
testcase_19 AC 81 ms
50,600 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 80 ms
50,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int xa = sc.nextInt();
        int ya = sc.nextInt();
        int xb = sc.nextInt();
        int yb = sc.nextInt();
        double left = 0;
        double right = 1000;
        for (int i = 0; i < 1000000; i++) {
            double m1 = (left * 2 + right) / 3;
            double m2 = (left + right * 2) / 3;
            double d1 = Math.sqrt(Math.pow(xa, 2) + Math.pow(ya - m1, 2)) + Math.sqrt(Math.pow(xb, 2) + Math.pow(yb - m1, 2));
            double d2 = Math.sqrt(Math.pow(xa, 2) + Math.pow(ya - m2, 2)) + Math.sqrt(Math.pow(xb, 2) + Math.pow(yb - m2, 2));
            if (d1 < d2) {
                right = m2;
            } else {
                left = m1;
            }
        }
        System.out.println(left);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0