結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー 👑 yumechiyumechi
提出日時 2017-06-09 22:43:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 187 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 57,028 KB
最終ジャッジ日時 2023-10-23 22:13:46
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,464 KB
testcase_01 AC 37 ms
53,464 KB
testcase_02 AC 37 ms
53,464 KB
testcase_03 AC 37 ms
53,464 KB
testcase_04 AC 39 ms
53,464 KB
testcase_05 AC 38 ms
53,464 KB
testcase_06 AC 38 ms
53,464 KB
testcase_07 AC 38 ms
53,464 KB
testcase_08 AC 40 ms
57,028 KB
testcase_09 AC 42 ms
57,028 KB
testcase_10 AC 65 ms
57,028 KB
testcase_11 AC 164 ms
57,028 KB
testcase_12 AC 164 ms
57,028 KB
testcase_13 AC 165 ms
57,028 KB
testcase_14 AC 165 ms
57,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, m = map(int, input().split())
    a1, a2 = 0, 1
    for i in range(2, n+1):
        a1, a2 = (a1 + a2) % m, a1 % m
    print(a1)


if __name__=="__main__":
    solve()
0