結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-10 19:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 215 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 76,172 KB
最終ジャッジ日時 2023-09-22 15:31:19
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,372 KB
testcase_01 AC 73 ms
71,436 KB
testcase_02 AC 71 ms
71,260 KB
testcase_03 AC 70 ms
71,292 KB
testcase_04 AC 74 ms
71,316 KB
testcase_05 AC 71 ms
71,360 KB
testcase_06 AC 72 ms
71,380 KB
testcase_07 AC 73 ms
71,292 KB
testcase_08 AC 75 ms
75,312 KB
testcase_09 AC 76 ms
75,360 KB
testcase_10 AC 94 ms
75,716 KB
testcase_11 AC 168 ms
75,816 KB
testcase_12 AC 167 ms
75,780 KB
testcase_13 AC 169 ms
76,172 KB
testcase_14 AC 170 ms
75,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    if N == 0:
        return 0
    if N == 1:
        return 1

    a, b = 1, 0
    for _ in range(N - 2):
        a, b = (a + b) % M, a
    return a


print(main())
0