結果

問題 No.533 Mysterious Stairs
ユーザー letrangerjpletrangerjp
提出日時 2017-06-23 22:57:32
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 222 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2024-04-15 00:58:55
合計ジャッジ時間 3,512 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
12,416 KB
testcase_01 AC 86 ms
12,288 KB
testcase_02 AC 78 ms
12,416 KB
testcase_03 AC 81 ms
12,160 KB
testcase_04 AC 78 ms
12,160 KB
testcase_05 AC 78 ms
12,288 KB
testcase_06 AC 80 ms
12,416 KB
testcase_07 AC 80 ms
12,288 KB
testcase_08 AC 76 ms
12,288 KB
testcase_09 AC 75 ms
12,160 KB
testcase_10 AC 83 ms
12,160 KB
testcase_11 AC 86 ms
12,544 KB
testcase_12 AC 80 ms
12,672 KB
testcase_13 AC 92 ms
13,056 KB
testcase_14 AC 83 ms
13,184 KB
testcase_15 AC 90 ms
13,824 KB
testcase_16 AC 113 ms
15,104 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M = 10**9+7

$dp = {}
def f(n, i)
  $dp[[n,i]] ||= if n == 0
    1
  elsif n < 0
    0
  else
    [1,2,3].map{|j|
      j == i ? 0 : f(n - j, j)
    }.sum % M
  end
end

N = gets.to_i
p [1,2,3].map{|i| f(N-i, i) }.sum % M
0