結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-04 08:59:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 943 ms / 2,000 ms
コード長 144 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 94,472 KB
最終ジャッジ日時 2023-10-20 00:39:30
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,120 KB
testcase_01 AC 86 ms
16,120 KB
testcase_02 AC 85 ms
16,120 KB
testcase_03 AC 87 ms
16,120 KB
testcase_04 AC 86 ms
16,120 KB
testcase_05 AC 89 ms
16,120 KB
testcase_06 AC 84 ms
16,120 KB
testcase_07 AC 85 ms
16,120 KB
testcase_08 AC 85 ms
16,376 KB
testcase_09 AC 100 ms
17,976 KB
testcase_10 AC 250 ms
31,932 KB
testcase_11 AC 925 ms
94,472 KB
testcase_12 AC 943 ms
94,472 KB
testcase_13 AC 922 ms
94,472 KB
testcase_14 AC 934 ms
94,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.chomp.split.map(&:to_i)

f = [] * (n + 1)
f[1] = 0
f[2] = 1
(3..n).to_a.each do |i|
  f[i] = (f[i - 1] + f[i - 2]) % m
end
puts f[n]
0