結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー hanorverhanorver
提出日時 2017-06-09 22:39:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 172 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-10-23 22:12:05
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,168 KB
testcase_01 AC 29 ms
10,168 KB
testcase_02 AC 28 ms
10,168 KB
testcase_03 AC 28 ms
10,168 KB
testcase_04 AC 28 ms
10,168 KB
testcase_05 WA -
testcase_06 AC 29 ms
10,168 KB
testcase_07 AC 29 ms
10,168 KB
testcase_08 AC 31 ms
10,168 KB
testcase_09 AC 47 ms
10,168 KB
testcase_10 AC 207 ms
10,168 KB
testcase_11 AC 1,223 ms
10,168 KB
testcase_12 AC 760 ms
10,168 KB
testcase_13 AC 1,330 ms
10,168 KB
testcase_14 AC 1,155 ms
10,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

f1 = 0
f2 = 1

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

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