結果

問題 No.419 直角三角形
ユーザー はむ吉🐹
提出日時 2016-09-10 12:01:52
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 352 bytes
コンパイル時間 4,090 ms
コンパイル使用メモリ 177,280 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 19:53:25
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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

ソースコード

diff #

import Control.Applicative ((<$>))
import Text.Printf (printf)

solve :: RealFloat a => a -> a -> a
solve a b
    | c /= d = sqrt $ d * d - c * c
    | otherwise = sqrt $ c * c + d * d
    where
        c = min a b
        d = max a b

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Double]
    printf "%.12f\n" $ solve a b
0