結果

問題 No.533 Mysterious Stairs
ユーザー 0w10w1
提出日時 2017-08-09 01:40:48
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 255 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 820,352 KB
最終ジャッジ日時 2024-04-20 05:23:47
合計ジャッジ時間 5,417 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,288 KB
testcase_01 AC 94 ms
12,160 KB
testcase_02 AC 89 ms
12,288 KB
testcase_03 AC 85 ms
12,160 KB
testcase_04 AC 101 ms
12,032 KB
testcase_05 AC 78 ms
12,032 KB
testcase_06 AC 94 ms
12,288 KB
testcase_07 AC 87 ms
12,288 KB
testcase_08 AC 88 ms
12,160 KB
testcase_09 AC 95 ms
12,288 KB
testcase_10 AC 82 ms
12,160 KB
testcase_11 AC 87 ms
12,288 KB
testcase_12 AC 100 ms
12,032 KB
testcase_13 AC 97 ms
12,160 KB
testcase_14 AC 105 ms
12,288 KB
testcase_15 AC 89 ms
12,416 KB
testcase_16 AC 107 ms
13,824 KB
testcase_17 AC 132 ms
16,256 KB
testcase_18 AC 141 ms
23,040 KB
testcase_19 AC 179 ms
29,440 KB
testcase_20 MLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

MOD = 1e9.to_i + 7

N = gets.to_i

dp = Array.new(N + 1) { [0] * 4 }
dp[0][0] = 1

N.times do |i|
  4.times do |j|
    1.upto(3) do |k|
      dp[i + k][k] = (dp[i + k][k] + dp[i][j]) if i + k <= N && j != k
    end
  end
end

puts (dp[N].inject :+) % MOD
0