結果

問題 No.533 Mysterious Stairs
ユーザー HERROHERRO
提出日時 2017-06-23 23:58:21
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 85,116 KB
最終ジャッジ日時 2024-04-15 01:11:20
合計ジャッジ時間 15,425 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 WA -
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 84 ms
12,160 KB
testcase_04 AC 88 ms
12,416 KB
testcase_05 AC 85 ms
12,288 KB
testcase_06 AC 85 ms
12,160 KB
testcase_07 AC 85 ms
12,160 KB
testcase_08 AC 85 ms
12,032 KB
testcase_09 AC 86 ms
12,288 KB
testcase_10 AC 87 ms
12,288 KB
testcase_11 AC 105 ms
13,440 KB
testcase_12 AC 142 ms
16,768 KB
testcase_13 AC 222 ms
24,576 KB
testcase_14 AC 248 ms
26,880 KB
testcase_15 AC 485 ms
33,920 KB
testcase_16 AC 1,568 ms
66,176 KB
testcase_17 AC 4,785 ms
78,304 KB
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
if n==1
 puts 1
 exit
elsif n==2
 puts 2
 exit
elsif n==3
 puts 3
 exit
end
m=10**9+7
a=Hash.new(0)
b=Hash.new(0)
c=Hash.new(0)
a[1]=1
b[2]=1
c[3]=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