結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー KoryKory
提出日時 2017-06-09 22:27:29
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,369 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 10,100 KB
最終ジャッジ日時 2023-10-23 21:40:37
合計ジャッジ時間 5,916 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,100 KB
testcase_01 AC 27 ms
10,100 KB
testcase_02 AC 27 ms
10,100 KB
testcase_03 AC 27 ms
10,100 KB
testcase_04 AC 28 ms
10,100 KB
testcase_05 AC 27 ms
10,100 KB
testcase_06 AC 26 ms
10,100 KB
testcase_07 AC 26 ms
10,100 KB
testcase_08 AC 28 ms
10,100 KB
testcase_09 AC 46 ms
10,100 KB
testcase_10 AC 208 ms
10,100 KB
testcase_11 AC 1,267 ms
10,100 KB
testcase_12 AC 806 ms
10,100 KB
testcase_13 AC 1,369 ms
10,100 KB
testcase_14 AC 1,185 ms
10,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def fib(prev, pprev, mod):
    return (prev + pprev) % mod, prev


def main():
    n, m = get_ln_int_inputs()
    current, prev = 1, 0
    for _ in range(n - 2):
        current, prev = fib(current, prev, m)
    print(current)


main()
0