結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,288 KB
testcase_01 AC 84 ms
12,288 KB
testcase_02 AC 92 ms
12,288 KB
testcase_03 AC 85 ms
12,288 KB
testcase_04 AC 88 ms
12,160 KB
testcase_05 AC 84 ms
12,160 KB
testcase_06 AC 83 ms
12,160 KB
testcase_07 AC 83 ms
12,288 KB
testcase_08 AC 85 ms
12,288 KB
testcase_09 AC 85 ms
12,288 KB
testcase_10 AC 89 ms
12,416 KB
testcase_11 AC 102 ms
13,696 KB
testcase_12 AC 140 ms
16,768 KB
testcase_13 AC 223 ms
24,704 KB
testcase_14 AC 250 ms
26,880 KB
testcase_15 AC 486 ms
33,792 KB
testcase_16 AC 1,596 ms
66,048 KB
testcase_17 AC 4,828 ms
78,204 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 1
 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