結果

問題 No.419 直角三角形
ユーザー Tsukasa_Type
提出日時 2018-03-06 14:52:14
言語 Java
(openjdk 23)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 368 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 74,216 KB
実行使用メモリ 41,664 KB
最終ジャッジ日時 2024-09-18 22:50:47
合計ジャッジ時間 6,245 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.System.*;

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