結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー ueyukiueyuki
提出日時 2017-06-21 05:45:55
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 189 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 19,360 KB
最終ジャッジ日時 2024-04-10 06:46:51
合計ジャッジ時間 4,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
19,360 KB
testcase_01 AC 84 ms
12,160 KB
testcase_02 AC 186 ms
12,160 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 367 ms
12,160 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def fibonati(n, m)
  if n == 1
    return 0
  end

  if n == 2
    return 1
  end

  return (fibonati(n-1, m) + fibonati(n-2, m)) % m
end

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

puts fibonati(n, m)
0