結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー kumatan400kumatan400
提出日時 2023-05-13 00:32:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 143 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 115,208 KB
最終ジャッジ日時 2023-08-19 06:55:09
合計ジャッジ時間 2,957 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
114,996 KB
testcase_01 AC 116 ms
115,076 KB
testcase_02 AC 108 ms
115,088 KB
testcase_03 AC 110 ms
114,904 KB
testcase_04 AC 109 ms
114,856 KB
testcase_05 AC 110 ms
115,000 KB
testcase_06 AC 111 ms
115,040 KB
testcase_07 AC 96 ms
114,908 KB
testcase_08 AC 109 ms
114,756 KB
testcase_09 AC 108 ms
114,996 KB
testcase_10 AC 107 ms
115,208 KB
testcase_11 AC 105 ms
114,896 KB
testcase_12 AC 95 ms
114,792 KB
testcase_13 AC 106 ms
115,048 KB
testcase_14 AC 96 ms
114,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

Z = 5 * 10**6
F = [0] * (Z+1)
F[2] = 1
for i in range(3, Z+1):
    F[i] = (F[i-1] + F[i-2]) % M

print(F[N])
0