結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー salmon0852salmon0852
提出日時 2021-12-25 14:50:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 137 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 135,672 KB
最終ジャッジ日時 2023-10-21 15:57:20
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,288 KB
testcase_01 AC 30 ms
53,288 KB
testcase_02 AC 31 ms
53,288 KB
testcase_03 AC 32 ms
53,288 KB
testcase_04 AC 30 ms
53,288 KB
testcase_05 AC 33 ms
53,288 KB
testcase_06 AC 31 ms
53,288 KB
testcase_07 AC 30 ms
53,288 KB
testcase_08 AC 33 ms
59,328 KB
testcase_09 AC 34 ms
58,848 KB
testcase_10 AC 44 ms
72,912 KB
testcase_11 AC 93 ms
135,672 KB
testcase_12 AC 79 ms
135,608 KB
testcase_13 AC 90 ms
135,672 KB
testcase_14 AC 80 ms
135,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
ans = [0, 1] + [0] * (n-2)
for i in range(2, n):
    ans[i] = (ans[i-2] + ans[i-1]) % m
print(ans[n-1])
0