結果
問題 |
No.419 直角三角形
|
ユーザー |
![]() |
提出日時 | 2018-09-17 14:34:48 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 896 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 104,320 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-07-18 07:39:54 |
合計ジャッジ時間 | 2,210 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var a = int.Parse(line[0]); var b = int.Parse(line[1]); Console.WriteLine(getAns(a,b)); } public static double getAns (int a, int b) { var ans = new double[2]; ans[0] = ans[1] = 1000000; if (b > a) return getAns(b, a); var w = Math.Sqrt(a * a + b * b); if (check(a, b, w)) ans[0] = w; var w2 = Math.Sqrt(a * a - b * b); if (check(a, b, w2)) ans[1] = w2; return ans.Min(); } public static bool check (int a, int b, double c) { var a2 = (double)a; var b2 = (double)b; if (a2 + b2 <= c) return false; if (a2 + c < b2) return false; if (b2 + c < a2) return false; return true; } }