結果

問題 No.533 Mysterious Stairs
ユーザー letrangerjpletrangerjp
提出日時 2017-06-23 23:21:58
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 315 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 811,136 KB
最終ジャッジ日時 2024-04-15 01:07:20
合計ジャッジ時間 12,911 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,288 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 88 ms
12,288 KB
testcase_03 AC 85 ms
12,160 KB
testcase_04 AC 86 ms
12,160 KB
testcase_05 AC 86 ms
12,288 KB
testcase_06 AC 84 ms
12,160 KB
testcase_07 AC 85 ms
12,288 KB
testcase_08 AC 84 ms
12,160 KB
testcase_09 AC 86 ms
12,160 KB
testcase_10 AC 85 ms
12,288 KB
testcase_11 AC 90 ms
12,416 KB
testcase_12 AC 93 ms
12,672 KB
testcase_13 AC 94 ms
13,312 KB
testcase_14 AC 95 ms
13,184 KB
testcase_15 AC 101 ms
13,824 KB
testcase_16 AC 118 ms
15,232 KB
testcase_17 AC 138 ms
17,408 KB
testcase_18 AC 167 ms
20,608 KB
testcase_19 AC 189 ms
22,272 KB
testcase_20 AC 1,532 ms
134,884 KB
testcase_21 AC 1,816 ms
148,072 KB
testcase_22 TLE -
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M = 10**9+7

$dp = {}
def f(n, i, level=0)
  $dp[[n,i]] ||= if n == 0
    1
  elsif n < 0
    0
  else
    [1,2,3].map{|j|
      if j == i
       0
      elsif level > 200
        Fiber.new { f(n - j, j, 0) }.resume
      else
        f(n - j, j, level+1)
      end
    }.sum % M
  end
end

N = gets.to_i
p f(N, 0)
0