結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mitsuo
提出日時 2017-06-20 13:16:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 883 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-10-02 04:45:23
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def fab(k, m):
    cache = [0, 1]

    while(k > 1):
        cache.append((cache[0] + cache[1]) % m)
        del cache[0]
        k -= 1

    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