結果

問題 No.554 recurrence formula
ユーザー Asdf_QwertyZAsdf_QwertyZ
提出日時 2017-09-03 00:36:43
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 300 bytes
コンパイル時間 3,967 ms
コンパイル使用メモリ 175,744 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-04-24 10:58:14
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,504 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 3 ms
5,632 KB
testcase_16 AC 2 ms
5,504 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 18 ms
14,464 KB
testcase_20 AC 18 ms
14,592 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Data.List (unfoldr)

m :: Int
m = 10^9+7

main :: IO ()
main = do
  n <- readLn

  print $ (!!(n-1)) $ flip unfoldr (1,0,1) $ \(i,evenS,oddS) -> case even i of
    True  -> Just (i*oddS`mod`m, (i+1, evenS+i*oddS`mod`m, oddS))
    False -> Just (i*evenS`mod`m, (i+1, evenS, oddS+i*evenS`mod`m))
0