結果

問題 No.419 直角三角形
ユーザー ym678ym678
提出日時 2016-09-27 13:02:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 411 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 74,444 KB
実行使用メモリ 41,796 KB
最終ジャッジ日時 2024-05-01 05:41:57
合計ジャッジ時間 5,894 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,580 KB
testcase_01 AC 125 ms
41,096 KB
testcase_02 AC 128 ms
41,752 KB
testcase_03 AC 127 ms
41,684 KB
testcase_04 AC 123 ms
41,208 KB
testcase_05 AC 113 ms
41,272 KB
testcase_06 AC 126 ms
41,616 KB
testcase_07 AC 124 ms
41,536 KB
testcase_08 AC 123 ms
41,548 KB
testcase_09 AC 126 ms
41,552 KB
testcase_10 AC 120 ms
40,152 KB
testcase_11 AC 128 ms
41,400 KB
testcase_12 AC 114 ms
41,252 KB
testcase_13 AC 128 ms
41,444 KB
testcase_14 AC 126 ms
41,444 KB
testcase_15 AC 126 ms
41,796 KB
testcase_16 AC 114 ms
41,412 KB
testcase_17 AC 129 ms
41,188 KB
testcase_18 AC 128 ms
41,664 KB
testcase_19 AC 124 ms
41,300 KB
testcase_20 AC 126 ms
41,272 KB
testcase_21 AC 124 ms
41,188 KB
testcase_22 AC 125 ms
41,580 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