結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー trineutrontrineutron
提出日時 2020-04-09 02:04:50
言語 Haskell
(9.6.2)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 819 bytes
コンパイル時間 12,895 ms
コンパイル使用メモリ 160,932 KB
実行使用メモリ 9,124 KB
最終ジャッジ日時 2023-09-29 22:51:54
合計ジャッジ時間 8,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,140 KB
testcase_01 AC 3 ms
7,228 KB
testcase_02 AC 3 ms
7,408 KB
testcase_03 AC 3 ms
7,436 KB
testcase_04 AC 4 ms
8,280 KB
testcase_05 AC 3 ms
7,700 KB
testcase_06 AC 5 ms
8,480 KB
testcase_07 AC 5 ms
8,512 KB
testcase_08 AC 5 ms
8,784 KB
testcase_09 AC 5 ms
9,124 KB
testcase_10 AC 4 ms
7,156 KB
testcase_11 AC 4 ms
7,864 KB
testcase_12 AC 4 ms
7,636 KB
testcase_13 AC 3 ms
7,196 KB
testcase_14 AC 2 ms
7,264 KB
testcase_15 AC 5 ms
8,244 KB
testcase_16 AC 4 ms
7,236 KB
testcase_17 AC 3 ms
7,224 KB
testcase_18 AC 4 ms
8,276 KB
testcase_19 AC 3 ms
7,612 KB
testcase_20 AC 3 ms
7,216 KB
testcase_21 AC 2 ms
7,280 KB
testcase_22 AC 3 ms
7,472 KB
testcase_23 AC 4 ms
8,684 KB
testcase_24 AC 3 ms
7,904 KB
testcase_25 AC 3 ms
7,156 KB
testcase_26 AC 3 ms
7,128 KB
testcase_27 AC 2 ms
7,348 KB
testcase_28 AC 3 ms
7,080 KB
testcase_29 AC 3 ms
7,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List.Split

main :: IO ()
main = do
    getLine
    a <- map parse . lines <$> getContents
    let (i, p) = (sum $ map fst a, sum $ map snd a)
    putStrLn $ showWithPoint(10^10 * i + p)

parse :: String -> (Integer, Integer)
parse = zipInt . splitWhen (== '.')

zipInt :: [String] -> (Integer, Integer)
zipInt [a, b]
    | head a /= '-' = (read a, readPoint b)
    | otherwise = (read a, -readPoint b)
zipInt [a] = (read a, 0)

readPoint :: String -> Integer
readPoint = read . take 10 . (++ repeat '0')

showWithPoint :: Integer -> String
showWithPoint x
    | x < 0 = '-':showWithPoint (-x)
    | otherwise = (show (x `div` 10 ^ 10)) ++ "." ++ (show10 10 (x `mod` 10^10))

show10 :: Integer -> Integer -> String
show10 0 _ = ""
show10 d x = (show $ x `div` 10^(d-1)) ++ show10 (d - 1) (x `mod` 10^(d-1))
0