結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー hanorverhanorver
提出日時 2017-06-09 22:44:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,345 ms / 2,000 ms
コード長 174 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 11,856 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-10-23 22:13:53
合計ジャッジ時間 6,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

n, m = map(int, input().split())

f1 = 0
f2 = 1

for i in range((n - 1) // 2):
    f1 = (f1 + f2) % m
    f2 = (f1 + f2) % m

if n % 2 == 1:
    print(f1)
else:
    print(f2)
0