結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー nbisconbisco
提出日時 2018-04-29 22:09:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,354 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,528 KB
実行使用メモリ 205,392 KB
最終ジャッジ日時 2023-09-10 08:12:08
合計ジャッジ時間 5,935 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,900 KB
testcase_01 AC 16 ms
7,792 KB
testcase_02 AC 15 ms
7,728 KB
testcase_03 AC 16 ms
7,804 KB
testcase_04 AC 15 ms
7,904 KB
testcase_05 AC 15 ms
7,796 KB
testcase_06 AC 15 ms
7,796 KB
testcase_07 AC 15 ms
7,912 KB
testcase_08 AC 18 ms
8,172 KB
testcase_09 AC 37 ms
12,032 KB
testcase_10 AC 220 ms
47,348 KB
testcase_11 AC 1,278 ms
203,948 KB
testcase_12 AC 715 ms
47,104 KB
testcase_13 AC 1,354 ms
205,392 KB
testcase_14 AC 1,241 ms
204,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = [int(i) for i in input().strip().split(" ")]

fib_base = [0 % m, 1 % m]
def fib(n):
    for i in range(2, n):
        fib_base.append((fib_base[i-1] + fib_base[i-2]) % m)

fib(n)
print(fib_base[-1])
0