結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-04 01:57:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 214 bytes |
| 記録 | |
| コンパイル時間 | 603 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 80,000 KB |
| 最終ジャッジ日時 | 2024-10-13 19:50:43 |
| 合計ジャッジ時間 | 2,417 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 RE * 7 |
ソースコード
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))