結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-03-22 22:45:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 148 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 11,408 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-09-07 01:54:36
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,300 KB
testcase_01 AC 78 ms
15,252 KB
testcase_02 AC 78 ms
15,252 KB
testcase_03 AC 77 ms
15,052 KB
testcase_04 AC 78 ms
15,172 KB
testcase_05 AC 76 ms
15,152 KB
testcase_06 AC 77 ms
15,132 KB
testcase_07 AC 78 ms
15,196 KB
testcase_08 AC 79 ms
15,192 KB
testcase_09 AC 88 ms
15,252 KB
testcase_10 AC 166 ms
15,252 KB
testcase_11 AC 492 ms
15,176 KB
testcase_12 AC 477 ms
15,128 KB
testcase_13 AC 492 ms
15,272 KB
testcase_14 AC 484 ms
15,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
prev = 0
current = 1

(N - 2).times do
  temp = prev + current
  prev = current
  current = temp % M
end

puts current
0