結果

問題 No.658 テトラナッチ数列 Hard
ユーザー pekempeypekempey
提出日時 2018-03-02 23:49:56
言語 Haskell
(9.8.2)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 11,535 ms
コンパイル使用メモリ 164,456 KB
実行使用メモリ 11,216 KB
最終ジャッジ日時 2023-09-04 21:26:52
合計ジャッジ時間 13,131 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,880 KB
testcase_01 AC 3 ms
7,668 KB
testcase_02 AC 3 ms
7,808 KB
testcase_03 AC 4 ms
8,512 KB
testcase_04 AC 32 ms
11,120 KB
testcase_05 AC 32 ms
11,216 KB
testcase_06 AC 32 ms
11,132 KB
testcase_07 AC 32 ms
11,188 KB
testcase_08 AC 32 ms
11,188 KB
testcase_09 AC 42 ms
11,188 KB
testcase_10 AC 42 ms
11,128 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 (0, 4911) 0 :: IO (IOUArray Int Int)
  writeArray dp 3 1

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

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