結果

問題 No.306 さいたま2008
ユーザー tenten
提出日時 2022-07-30 09:53:36
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 77,592 KB
実行使用メモリ 51,268 KB
最終ジャッジ日時 2024-07-20 05:29:40
合計ジャッジ時間 5,397 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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