結果

問題 No.419 直角三角形
ユーザー ym678ym678
提出日時 2016-09-27 13:02:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 411 bytes
コンパイル時間 4,530 ms
コンパイル使用メモリ 71,188 KB
実行使用メモリ 56,088 KB
最終ジャッジ日時 2023-08-13 12:25:49
合計ジャッジ時間 8,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,768 KB
testcase_01 AC 124 ms
53,956 KB
testcase_02 AC 123 ms
55,812 KB
testcase_03 AC 122 ms
55,804 KB
testcase_04 AC 123 ms
55,988 KB
testcase_05 AC 123 ms
55,856 KB
testcase_06 AC 122 ms
55,824 KB
testcase_07 AC 122 ms
55,544 KB
testcase_08 AC 120 ms
56,088 KB
testcase_09 AC 120 ms
56,000 KB
testcase_10 AC 122 ms
55,912 KB
testcase_11 AC 121 ms
55,804 KB
testcase_12 AC 122 ms
55,764 KB
testcase_13 AC 124 ms
55,856 KB
testcase_14 AC 122 ms
55,984 KB
testcase_15 AC 121 ms
53,992 KB
testcase_16 AC 122 ms
55,804 KB
testcase_17 AC 123 ms
55,852 KB
testcase_18 AC 123 ms
55,744 KB
testcase_19 AC 122 ms
55,812 KB
testcase_20 AC 120 ms
55,956 KB
testcase_21 AC 122 ms
55,844 KB
testcase_22 AC 121 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		
		if(a == b){
			double ans = Math.sqrt(a*a+b*b);			
			System.out.println(ans);
		}else{
			if(a<b){
				int sub = a;
				a = b;
				b = sub; 
			}
			double ans = Math.sqrt(a*a-b*b);			
			System.out.println(ans);
		}
		

	}
}
0