結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,524 KB
testcase_01 AC 19 ms
8,532 KB
testcase_02 AC 21 ms
8,528 KB
testcase_03 AC 21 ms
8,580 KB
testcase_04 AC 20 ms
8,556 KB
testcase_05 AC 20 ms
8,732 KB
testcase_06 AC 20 ms
8,544 KB
testcase_07 AC 21 ms
9,296 KB
testcase_08 RE -
testcase_09 RE -
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(10000)

@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