結果

問題 No.533 Mysterious Stairs
ユーザー ikdikd
提出日時 2017-06-23 23:48:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,929 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 102,656 KB
最終ジャッジ日時 2024-04-15 01:08:37
合計ジャッジ時間 14,379 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,288 KB
testcase_01 AC 93 ms
12,288 KB
testcase_02 AC 86 ms
12,160 KB
testcase_03 AC 83 ms
12,288 KB
testcase_04 AC 81 ms
12,288 KB
testcase_05 AC 83 ms
12,288 KB
testcase_06 AC 82 ms
12,160 KB
testcase_07 AC 82 ms
12,160 KB
testcase_08 AC 85 ms
12,160 KB
testcase_09 AC 86 ms
12,160 KB
testcase_10 AC 87 ms
12,288 KB
testcase_11 AC 85 ms
12,160 KB
testcase_12 AC 87 ms
12,160 KB
testcase_13 AC 86 ms
12,288 KB
testcase_14 AC 84 ms
12,160 KB
testcase_15 AC 86 ms
12,288 KB
testcase_16 AC 90 ms
12,288 KB
testcase_17 AC 99 ms
12,288 KB
testcase_18 AC 106 ms
12,416 KB
testcase_19 AC 111 ms
12,672 KB
testcase_20 AC 403 ms
21,760 KB
testcase_21 AC 449 ms
22,784 KB
testcase_22 AC 1,203 ms
46,976 KB
testcase_23 AC 2,870 ms
101,504 KB
testcase_24 AC 2,929 ms
102,656 KB
testcase_25 AC 417 ms
21,632 KB
testcase_26 AC 2,587 ms
90,368 KB
testcase_27 AC 832 ms
35,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
mod=10**9+7

ikd=Array.new(n+1){Array.new(4){0}}
n.times do |i|
  (1..3).each do |j|
    if i==0
      if i+j<=n
        ikd[i+j][j]+=1
      end
    else
      (1..3).each do |k|
        if j!=k
          if i+j<=n
            ikd[i+j][j]+=ikd[i][k]
            ikd[i+j][j]%=mod
          end
        end
      end
    end
  end
end

puts (ikd[n][1]+ikd[n][2]+ikd[n][3])%mod
0