結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー surprise_tanaka
提出日時 2018-12-03 01:36:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 219 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-01 05:32:24
合計ジャッジ時間 1,370 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize = None)
def fib(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    return fib(n-1) + fib(n-2)

N,M = map(int,input().split())
print(fib(N-1) % M)
0