結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー gemmarogemmaro
提出日時 2019-11-15 08:43:46
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 188 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 16,080 KB
最終ジャッジ日時 2023-10-24 03:29:53
合計ジャッジ時間 5,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
16,080 KB
testcase_01 AC 82 ms
16,080 KB
testcase_02 AC 170 ms
16,080 KB
testcase_03 AC 84 ms
16,080 KB
testcase_04 AC 311 ms
16,080 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 #

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

def fib(n)
    case n
    when 1
        return 0
    when 2
        return 1
    else
        return fib(n - 1) + fib(n - 2)
    end
end

p fib(n) % m
0