結果
問題 | No.419 直角三角形 |
ユーザー |
![]() |
提出日時 | 2016-09-09 22:25:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 132 ms / 1,000 ms |
コード長 | 1,669 bytes |
コンパイル時間 | 2,564 ms |
コンパイル使用メモリ | 79,316 KB |
実行使用メモリ | 54,024 KB |
最終ジャッジ日時 | 2024-11-16 09:42:26 |
合計ジャッジ時間 | 6,241 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final int a = sc.nextInt(); final int b = sc.nextInt(); final int max = Math.max(a, b); final int min = Math.min(a, b); if(max == min){ System.out.printf("%.8f\n", Math.sqrt(max * max + min * min)); }else{ System.out.printf("%.8f\n", Math.min(Math.sqrt(max * max - min * min), Math.sqrt(max * max + min * min))); } } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public void close() throws IOException { br.close(); } } }