結果
問題 | No.419 直角三角形 |
ユーザー |
![]() |
提出日時 | 2016-09-09 22:45:17 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 6,583 ms |
コンパイル使用メモリ | 181,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 10:37:17 |
合計ジャッジ時間 | 7,407 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
LANGUAGEimportqualifiedData.ByteString.CharasCimportData.CharimportText.Printfsolve::Int->Int->Doublesolve a b| a == b = sqrt $ x ** 2 + y ** 2| otherwise = sqrt $ x ** 2 - y ** 2where a2 = realToFrac ab2 = realToFrac bx = max a2 b2y = min a2 b2main::IO()main = doss <- C.getLinelet (a, ss2) = nextInt sslet (b, ss3) = nextInt ss2printf "%.20f\n" $ solve a bnextInt::CByteString->IntCByteStringnextInt ss| isDigit x || x == '-' = nextInt2 0 ss| otherwise = nextInt $ C.tail sswhere x = C.head ssnextInt2::Int->CByteString->IntCByteStringnextInt2 n ss| C.null ss = (n, ss)| y == '-' = (-z,zs)| isDigit y = nextInt2 (n * 10 + (digitToInt y)) ys| otherwise = (n, ys)where y = C.head ssys = C.tail ss(z,zs) = nextInt2 0 ys