結果
| 問題 | No.657 テトラナッチ数列 Easy |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-03 22:04:21 |
| 言語 | Haskell (9.10.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 8,721 ms |
| コンパイル使用メモリ | 180,428 KB |
| 実行使用メモリ | 13,696 KB |
| 最終ジャッジ日時 | 2024-07-04 18:19:39 |
| 合計ジャッジ時間 | 14,498 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 1 -- * 3 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
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