結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
![]() |
提出日時 | 2021-08-16 21:26:09 |
言語 | Haskell (9.10.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 309 bytes |
コンパイル時間 | 7,130 ms |
コンパイル使用メモリ | 201,188 KB |
実行使用メモリ | 718,912 KB |
最終ジャッジ日時 | 2024-10-09 18:41:19 |
合計ジャッジ時間 | 11,747 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 MLE * 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 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