結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー JunOnumaJunOnuma
提出日時 2017-06-12 14:40:27
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,255 ms / 2,000 ms
コード長 159 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 7,180 KB
実行使用メモリ 6,428 KB
最終ジャッジ日時 2023-10-24 21:32:30
合計ジャッジ時間 6,014 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,428 KB
testcase_01 AC 10 ms
6,428 KB
testcase_02 AC 9 ms
6,428 KB
testcase_03 AC 9 ms
6,428 KB
testcase_04 AC 10 ms
6,428 KB
testcase_05 AC 12 ms
6,428 KB
testcase_06 AC 11 ms
6,428 KB
testcase_07 AC 11 ms
6,428 KB
testcase_08 AC 13 ms
6,428 KB
testcase_09 AC 37 ms
6,428 KB
testcase_10 AC 257 ms
6,428 KB
testcase_11 AC 1,251 ms
6,428 KB
testcase_12 AC 1,255 ms
6,428 KB
testcase_13 AC 1,247 ms
6,428 KB
testcase_14 AC 1,248 ms
6,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int, raw_input().split())
a = 0
b = 1
i = 2
while i < n:
    c = (a + b) % m
    a = b
    b = c
    i += 1
if i == 0:
    print a
else:
    print b
0