結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー flippergoflippergo
提出日時 2021-01-04 01:57:12
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 214 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 80,000 KB
最終ジャッジ日時 2024-04-21 21:28:31
合計ジャッジ時間 2,712 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,456 KB
testcase_01 AC 40 ms
51,840 KB
testcase_02 AC 40 ms
51,840 KB
testcase_03 AC 47 ms
51,584 KB
testcase_04 AC 48 ms
51,328 KB
testcase_05 AC 53 ms
51,968 KB
testcase_06 AC 50 ms
51,712 KB
testcase_07 AC 54 ms
58,112 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
memo = {}
def f(x):
    if x==1:
        return 0
    if x==2:
        return 1
    if x in memo:
        return memo[x]
    memo[x] = (f(x-1)+f(x-2))%M
    return memo[x]
print(f(N))
0