結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー Cyberdog-しばいぬ-Cyberdog-しばいぬ-
提出日時 2019-02-06 16:09:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 252 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 817,012 KB
最終ジャッジ日時 2023-09-02 13:34:11
合計ジャッジ時間 3,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,616 KB
testcase_01 AC 19 ms
8,616 KB
testcase_02 AC 19 ms
8,724 KB
testcase_03 AC 19 ms
8,572 KB
testcase_04 AC 20 ms
8,752 KB
testcase_05 AC 20 ms
8,564 KB
testcase_06 AC 20 ms
8,656 KB
testcase_07 AC 21 ms
9,424 KB
testcase_08 AC 34 ms
17,288 KB
testcase_09 AC 296 ms
91,100 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys

sys.setrecursionlimit(5 * 10**6)

N, M = map(int, input().split())


@lru_cache(maxsize=1000)
def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 1) + fib(n - 2)


print(fib(N-1) % M)
0