結果

問題 No.432 占い(Easy)
ユーザー atuk721atuk721
提出日時 2017-02-22 06:34:49
言語 Haskell
(9.8.2)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 161,956 KB
実行使用メモリ 31,812 KB
最終ジャッジ日時 2023-08-28 23:46:40
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,100 KB
testcase_01 AC 3 ms
7,028 KB
testcase_02 AC 2 ms
7,044 KB
testcase_03 AC 2 ms
7,136 KB
testcase_04 AC 3 ms
7,576 KB
testcase_05 AC 3 ms
7,080 KB
testcase_06 AC 2 ms
7,164 KB
testcase_07 AC 3 ms
7,568 KB
testcase_08 AC 2 ms
7,124 KB
testcase_09 AC 4 ms
8,540 KB
testcase_10 AC 3 ms
7,800 KB
testcase_11 AC 12 ms
11,224 KB
testcase_12 AC 92 ms
31,812 KB
testcase_13 AC 92 ms
31,168 KB
testcase_14 AC 12 ms
11,220 KB
testcase_15 AC 2 ms
7,180 KB
testcase_16 AC 3 ms
7,076 KB
testcase_17 AC 83 ms
31,716 KB
testcase_18 AC 42 ms
15,644 KB
testcase_19 AC 23 ms
13,936 KB
testcase_20 AC 12 ms
11,532 KB
testcase_21 AC 11 ms
12,356 KB
testcase_22 AC 3 ms
7,852 KB
testcase_23 AC 3 ms
8,020 KB
testcase_24 AC 3 ms
8,616 KB
testcase_25 AC 4 ms
8,600 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 qualified Control.Monad as M
import qualified Data.Char as C

main :: IO ()
main = do
  t <- read <$> getLine
  M.forM_ [1..t] $ \i -> do
    ss <- map C.digitToInt <$> getLine
    print $ proc ss

proc :: [Int] -> Int
proc ss = head . last . take (length ss) $ iterate sub ss

sub :: [Int] -> [Int]
sub [] = []
sub (_:[]) = []
sub (a:b:xs) = result : sub (b:xs)
  where result | a + b < 10 = a + b
               | otherwise  = ((a + b) `div` 10) + ((a + b) `mod` 10)
0