結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mitsuomitsuo
提出日時 2017-06-20 12:27:00
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,033 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 165,340 KB
最終ジャッジ日時 2024-04-10 03:14:58
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,812 KB
testcase_01 AC 10 ms
6,940 KB
testcase_02 AC 10 ms
6,944 KB
testcase_03 AC 10 ms
6,944 KB
testcase_04 AC 10 ms
6,944 KB
testcase_05 AC 10 ms
6,940 KB
testcase_06 AC 10 ms
6,940 KB
testcase_07 AC 10 ms
6,940 KB
testcase_08 AC 11 ms
6,940 KB
testcase_09 AC 30 ms
9,216 KB
testcase_10 AC 207 ms
38,004 KB
testcase_11 AC 992 ms
165,308 KB
testcase_12 AC 1,033 ms
165,304 KB
testcase_13 AC 996 ms
165,300 KB
testcase_14 AC 988 ms
165,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-



def fab(k, m):
    cache = [0, 1]
    for w in range(k - 1):
        cache.append((cache[0] + cache[1]) % m)
        del cache[0]

    return cache[0]


def solve(input):
    n = int(input.split(" ")[0])
    m = int(input.split(" ")[1])
    return fab(n,m)

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