結果

問題 No.657 テトラナッチ数列 Easy
ユーザー ducktailducktail
提出日時 2018-03-03 22:04:21
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 735 bytes
コンパイル時間 10,098 ms
コンパイル使用メモリ 164,944 KB
実行使用メモリ 15,168 KB
最終ジャッジ日時 2023-09-18 01:17:08
合計ジャッジ時間 16,535 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,104 KB
testcase_01 AC 3 ms
7,164 KB
testcase_02 AC 3 ms
7,136 KB
testcase_03 AC 3 ms
7,184 KB
testcase_04 AC 22 ms
7,152 KB
testcase_05 AC 12 ms
12,868 KB
testcase_06 AC 2 ms
7,100 KB
testcase_07 AC 3 ms
7,196 KB
testcase_08 AC 32 ms
7,112 KB
testcase_09 AC 112 ms
13,136 KB
testcase_10 AC 963 ms
13,264 KB
testcase_11 AC 962 ms
13,144 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative ((<$>))
import Control.Monad (replicateM)

import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  n <- getl $ readi B.readInt
  solve <$> replicateM n (getl $ readi B.readInt) >>= mapM_ print

solve :: [Int] -> [Int]
solve = map tnacci

tnacci :: Int -> Int
tnacci x | x == 1 = 0
         | x == 2 = 0
         | x == 3 = 0
         | otherwise = f x 0 0 0 1
  where
    f n a b c d | n == 4 = d
                | otherwise = f (n - 1) b c d $ (a + b + c + d) `mod` 17

getl :: (ByteString -> a) -> IO a
getl f = f <$> B.getLine

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n
0