結果

問題 No.419 直角三角形
ユーザー tentententen
提出日時 2023-02-15 11:47:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 1,817 bytes
コンパイル時間 3,158 ms
コンパイル使用メモリ 85,824 KB
実行使用メモリ 50,492 KB
最終ジャッジ日時 2023-09-24 21:31:38
合計ジャッジ時間 5,838 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
50,108 KB
testcase_01 AC 47 ms
49,876 KB
testcase_02 AC 48 ms
50,400 KB
testcase_03 AC 47 ms
49,864 KB
testcase_04 AC 47 ms
50,028 KB
testcase_05 AC 47 ms
49,932 KB
testcase_06 AC 48 ms
50,004 KB
testcase_07 AC 48 ms
50,396 KB
testcase_08 AC 48 ms
49,944 KB
testcase_09 AC 48 ms
50,212 KB
testcase_10 AC 48 ms
50,400 KB
testcase_11 AC 48 ms
49,872 KB
testcase_12 AC 47 ms
50,052 KB
testcase_13 AC 50 ms
50,104 KB
testcase_14 AC 48 ms
50,492 KB
testcase_15 AC 47 ms
49,932 KB
testcase_16 AC 47 ms
49,824 KB
testcase_17 AC 48 ms
49,972 KB
testcase_18 AC 47 ms
49,924 KB
testcase_19 AC 48 ms
49,972 KB
testcase_20 AC 47 ms
50,036 KB
testcase_21 AC 47 ms
49,984 KB
testcase_22 AC 48 ms
50,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int left = Math.min(a, b);
        int right = Math.max(a, b);
        double ans;
        if (left == right) {
            ans = Math.sqrt(Math.pow(left, 2) * 2);
        } else {
            ans = Math.sqrt(Math.pow(right, 2) - Math.pow(left, 2));
        }
        System.out.println(new java.math.BigDecimal(ans).toPlainString());
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0