結果
問題 | No.534 フィボナッチフィボナッチ数 |
ユーザー |
![]() |
提出日時 | 2017-08-04 22:26:53 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 2,873 ms |
コンパイル使用メモリ | 170,752 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 20:57:45 |
合計ジャッジ時間 | 2,641 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 42 |
コンパイルメッセージ
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
ソースコード
importData.Listtransposemodulo = 10 ^ 9 + 7period = 2 * (modulo + 1)fib_mat::Integerfib_mat = [[1, 1], [1, 0]]initial_vector::Integerinitial_vector = [[0], [1]]multiply::Integrala=>a->a->a->amultiply a b mo = map (\r -> map ((`mod` mo) . sum . zipWith (*) r) b') awhereb' = transpose bexpt::Integer->Integer->Integer->Integerexpt = expt' [[1, 0], [0, 1]]whereexpt' a _ 0 _ = aexpt' a b n mo| n `mod` 2 == 1 = expt' (multiply a b mo) b' n' mo| otherwise = expt' a b' n' mowheren' = n `div` 2b' = multiply b b momain = don <- readLnlet ([an]:_) = multiply (expt fib_mat n period) initial_vector period([bn]:_) = multiply (expt fib_mat an modulo) initial_vector moduloprint bn