結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー yukikurage_2019yukikurage_2019
提出日時 2021-08-16 21:26:09
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 309 bytes
コンパイル時間 15,422 ms
コンパイル使用メモリ 209,920 KB
実行使用メモリ 740,528 KB
最終ジャッジ日時 2024-04-18 00:57:08
合計ジャッジ時間 16,031 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 26 ms
21,420 KB
testcase_10 AC 444 ms
146,100 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 MLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import qualified Data.Vector as V

main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine
    print $ solve n m
    
solve :: Int -> Int -> Int
solve n m = dp V.! (n - 1)
    where
    dp = V.map f $ V.fromList [0 .. n - 1]
    f 0 = 0
    f 1 = 1
    f i = mod (dp V.! (i - 1) + dp V.! (i - 2)) m
0