結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー lemondolemondo
提出日時 2020-12-04 22:15:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 255 bytes
コンパイル時間 1,325 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 75,880 KB
最終ジャッジ日時 2023-10-13 12:03:03
合計ジャッジ時間 2,872 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,172 KB
testcase_01 AC 70 ms
71,144 KB
testcase_02 AC 71 ms
71,000 KB
testcase_03 AC 72 ms
71,136 KB
testcase_04 AC 73 ms
71,296 KB
testcase_05 AC 72 ms
71,124 KB
testcase_06 AC 72 ms
71,036 KB
testcase_07 AC 72 ms
71,288 KB
testcase_08 AC 77 ms
75,592 KB
testcase_09 AC 77 ms
75,684 KB
testcase_10 AC 82 ms
75,608 KB
testcase_11 AC 108 ms
75,880 KB
testcase_12 AC 89 ms
75,676 KB
testcase_13 AC 109 ms
75,764 KB
testcase_14 AC 90 ms
75,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
old = 0
new = 1
for i in range(2, N):
    new, old = old+new, new
    new %= M
    old %= M
print(new)
0