結果

問題 No.533 Mysterious Stairs
ユーザー HERROHERRO
提出日時 2017-06-23 23:51:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 90,732 KB
最終ジャッジ日時 2024-04-15 01:09:19
合計ジャッジ時間 15,036 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
m=10**9+7
a=Hash.new(0)
b=Hash.new(0)
c=Hash.new(0)
a[0]=1
b[0]=1
c[0]=1
ans=0
loop{
 x=Hash.new(0)
 y=Hash.new(0)
 z=Hash.new(0)
 a.each{|k,v|
  if k+2 < n
    y[k+2]=(y[k+2]+v)%m
  elsif k+2==n
    ans=(ans+v)%m
  end
  if k+3 < n
    z[k+3]=(z[k+3]+v)%m
  elsif k+3==n
    ans=(ans+v)%m
  end
 }
 b.each{|k,v|
  if k+1 < n
    x[k+1]=(x[k+1]+v)%m
  elsif k+1==n
    ans=(ans+v)%m
  end
  if k+3 < n
    z[k+3]=(z[k+3]+v)%m
  elsif k+3==n
    ans=(ans+v)%m
  end
 }
 c.each{|k,v|
  if k+1 < n
    x[k+1]=(x[k+1]+v)%m
  elsif k+1==n
    ans=(ans+v)%m
  end
  if k+2 < n
    y[k+2]=(y[k+2]+v)%m
  elsif k+2==n
    ans=(ans+v)%m
  end
 }
 a,b,c=x,y,z
 break if a.empty? && b.empty? && c.empty?
}
puts ans
0