結果

問題 No.533 Mysterious Stairs
ユーザー maimai
提出日時 2017-06-23 01:43:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 440 ms / 5,000 ms
コード長 451 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 35,712 KB
最終ジャッジ日時 2024-04-15 00:46:48
合計ジャッジ時間 4,650 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,416 KB
testcase_01 AC 77 ms
12,160 KB
testcase_02 AC 83 ms
12,288 KB
testcase_03 AC 87 ms
12,288 KB
testcase_04 AC 82 ms
12,288 KB
testcase_05 AC 78 ms
12,288 KB
testcase_06 AC 81 ms
12,288 KB
testcase_07 AC 81 ms
12,288 KB
testcase_08 AC 80 ms
12,288 KB
testcase_09 AC 78 ms
12,288 KB
testcase_10 AC 84 ms
12,288 KB
testcase_11 AC 82 ms
12,416 KB
testcase_12 AC 86 ms
12,160 KB
testcase_13 AC 87 ms
12,288 KB
testcase_14 AC 78 ms
12,288 KB
testcase_15 AC 81 ms
12,288 KB
testcase_16 AC 86 ms
12,288 KB
testcase_17 AC 83 ms
12,288 KB
testcase_18 AC 82 ms
12,288 KB
testcase_19 AC 83 ms
12,160 KB
testcase_20 AC 119 ms
14,848 KB
testcase_21 AC 128 ms
14,976 KB
testcase_22 AC 212 ms
21,248 KB
testcase_23 AC 440 ms
35,456 KB
testcase_24 AC 435 ms
35,712 KB
testcase_25 AC 123 ms
14,848 KB
testcase_26 AC 381 ms
32,512 KB
testcase_27 AC 170 ms
18,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end
def scan; gets.to_i; end

line = gets.chomp!
assert unless line=~/^\d+$/
assert unless !gets



MOD = 1000000007
n = line.to_i

dp1 = Array.new(n+4,0)
dp2 = Array.new(n+4,0)
dp3 = Array.new(n+4,0)

dp1[1] = 1
dp2[2] = 1
dp3[3] = 1

1.upto(n-1){|i|
    dp1[i+1] = (dp1[i+1]+dp2[i]+dp3[i])%MOD
    dp2[i+2] = (dp2[i+2]+dp1[i]+dp3[i])%MOD
    dp3[i+3] = (dp3[i+3]+dp1[i]+dp2[i])%MOD
}

p (dp1[n]+dp2[n]+dp3[n])%MOD
0