結果

問題 No.419 直角三角形
ユーザー alpha_virginisalpha_virginis
提出日時 2016-09-09 22:41:04
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 7,828 ms
コンパイル使用メモリ 180,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 02:19:10
合計ジャッジ時間 8,669 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as C
import Data.Char

solve :: Int -> Int -> Double
solve a b = sqrt $ x ** 2 - y ** 2
  where a2 = realToFrac a
        b2 = realToFrac b
        x  = max a2 b2
        y  = min a2 b2

main :: IO ()
main = do
  ss <- C.getLine
  let (a, ss2) = nextInt ss
  let (b, ss3) = nextInt ss2
  print $ solve a b

nextInt :: C.ByteString -> (Int, C.ByteString)
nextInt ss
  | isDigit x || x == '-' = nextInt2 0 ss
  | otherwise             = nextInt $ C.tail ss
  where x = C.head ss
  
nextInt2 :: Int -> C.ByteString -> (Int, C.ByteString)
nextInt2 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 ss
        ys = C.tail ss
        (z,zs) = nextInt2 0 ys
                           
0