結果

問題 No.533 Mysterious Stairs
ユーザー cielciel
提出日時 2017-06-25 17:34:11
言語 Ruby
(3.3.0)
結果
AC  
実行時間 440 ms / 5,000 ms
コード長 184 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 36,684 KB
最終ジャッジ日時 2024-04-14 23:42:45
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,288 KB
testcase_01 AC 89 ms
12,416 KB
testcase_02 AC 88 ms
12,160 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 89 ms
12,160 KB
testcase_05 AC 88 ms
12,160 KB
testcase_06 AC 88 ms
12,160 KB
testcase_07 AC 89 ms
12,288 KB
testcase_08 AC 88 ms
12,160 KB
testcase_09 AC 88 ms
12,160 KB
testcase_10 AC 87 ms
12,416 KB
testcase_11 AC 87 ms
12,288 KB
testcase_12 AC 87 ms
12,288 KB
testcase_13 AC 88 ms
12,160 KB
testcase_14 AC 87 ms
12,288 KB
testcase_15 AC 87 ms
12,160 KB
testcase_16 AC 87 ms
12,288 KB
testcase_17 AC 89 ms
12,160 KB
testcase_18 AC 90 ms
12,288 KB
testcase_19 AC 91 ms
12,416 KB
testcase_20 AC 128 ms
15,744 KB
testcase_21 AC 134 ms
17,280 KB
testcase_22 AC 222 ms
23,552 KB
testcase_23 AC 438 ms
36,584 KB
testcase_24 AC 440 ms
36,684 KB
testcase_25 AC 128 ms
16,128 KB
testcase_26 AC 392 ms
33,720 KB
testcase_27 AC 178 ms
21,632 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
M=10**9+7
a=[0,1,0,1]
b=[0,0,1,1]
c=[0,0,0,1]
n=gets.to_i
(4..n).each{|i|
	a[i]=(b[i-1]+c[i-1])%M
	b[i]=(a[i-2]+c[i-2])%M
	c[i]=(a[i-3]+b[i-3])%M
}
p (a[n]+b[n]+c[n])%M
0