結果

問題 No.657 テトラナッチ数列 Easy
ユーザー pekempeypekempey
提出日時 2018-03-02 23:47:52
言語 Haskell
(9.8.2)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 11,495 ms
コンパイル使用メモリ 166,284 KB
実行使用メモリ 18,312 KB
最終ジャッジ日時 2023-09-04 20:07:57
合計ジャッジ時間 14,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
18,276 KB
testcase_01 AC 72 ms
18,172 KB
testcase_02 AC 72 ms
18,280 KB
testcase_03 AC 73 ms
18,240 KB
testcase_04 AC 72 ms
18,308 KB
testcase_05 AC 82 ms
18,240 KB
testcase_06 AC 72 ms
18,312 KB
testcase_07 AC 72 ms
18,304 KB
testcase_08 AC 73 ms
18,300 KB
testcase_09 AC 92 ms
18,280 KB
testcase_10 AC 93 ms
18,172 KB
testcase_11 AC 92 ms
18,312 KB
testcase_12 AC 92 ms
18,236 KB
testcase_13 AC 92 ms
18,244 KB
testcase_14 AC 92 ms
18,212 KB
testcase_15 AC 92 ms
18,312 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.Array.IO
import Control.Monad

main = do
  q <- readLn :: IO Int

  dp <- newArray (1, 1000000) 0 :: IO (IOUArray Int Int)
  writeArray dp 4 1

  forM_ [5..1000000] $ \i ->
    sum <$> sequence [readArray dp (i - k) | k <- [1..4]]
    >>= return . flip mod 17
    >>= writeArray dp i

  forM_ [1..q] $ \i -> do
    n <- readLn :: IO Int
    readArray dp n >>= print
    
0