結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー ueyukiueyuki
提出日時 2017-06-21 16:27:02
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 203 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 7,808 KB
実行使用メモリ 817,536 KB
最終ジャッジ日時 2024-04-10 09:05:25
合計ジャッジ時間 4,064 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,288 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 92 ms
12,160 KB
testcase_03 AC 91 ms
12,288 KB
testcase_04 AC 90 ms
12,288 KB
testcase_05 AC 90 ms
12,416 KB
testcase_06 AC 90 ms
12,160 KB
testcase_07 AC 90 ms
12,160 KB
testcase_08 AC 100 ms
16,512 KB
testcase_09 AC 604 ms
443,008 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def fibonacci(num, n)

  i = 3;

  while i <= n
    num << num[i-1] + num[i-2]
    i += 1
  end

  return i;

end


n, m = gets.split.map(&:to_i)
num = [0, 0, 1]

i = fibonacci(num, n)

puts num[i-1] % m
0