結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー MarioMario
提出日時 2018-06-03 12:44:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 275 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 462,516 KB
最終ジャッジ日時 2023-09-12 21:48:28
合計ジャッジ時間 10,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,716 KB
testcase_01 AC 19 ms
8,600 KB
testcase_02 AC 20 ms
8,552 KB
testcase_03 AC 19 ms
8,664 KB
testcase_04 AC 20 ms
8,560 KB
testcase_05 AC 19 ms
8,592 KB
testcase_06 AC 19 ms
8,552 KB
testcase_07 AC 21 ms
9,432 KB
testcase_08 AC 35 ms
17,208 KB
testcase_09 AC 305 ms
91,136 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=1024)
def fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1) + fib(n-2)

n, m = map(int, input().split())
print(fib(n) % m)
0