結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2020-04-09 02:03:19 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 6,773 ms |
コンパイル使用メモリ | 171,776 KB |
実行使用メモリ | 5,760 KB |
最終ジャッジ日時 | 2024-07-19 06:30:02 |
合計ジャッジ時間 | 7,911 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 21 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:15:7: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 15 | | head a /= '-' = (read a, readPoint b) | ^^^^ [2 of 2] Linking a.out
ソースコード
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 `div` 10)