結果

問題 No.314 ケンケンパ
ユーザー cympfhcympfh
提出日時 2015-12-09 16:26:28
言語 Ruby
(3.2.2)
結果
AC  
実行時間 227 ms / 1,000 ms
コード長 186 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 23,148 KB
最終ジャッジ日時 2023-10-13 08:42:21
合計ジャッジ時間 3,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 218 ms
23,148 KB
testcase_01 AC 71 ms
15,268 KB
testcase_02 AC 76 ms
15,260 KB
testcase_03 AC 71 ms
15,220 KB
testcase_04 AC 71 ms
15,260 KB
testcase_05 AC 75 ms
15,272 KB
testcase_06 AC 72 ms
15,068 KB
testcase_07 AC 73 ms
15,232 KB
testcase_08 AC 74 ms
15,096 KB
testcase_09 AC 74 ms
15,100 KB
testcase_10 AC 73 ms
15,280 KB
testcase_11 AC 74 ms
15,176 KB
testcase_12 AC 72 ms
15,052 KB
testcase_13 AC 76 ms
15,124 KB
testcase_14 AC 79 ms
15,140 KB
testcase_15 AC 80 ms
15,068 KB
testcase_16 AC 79 ms
15,400 KB
testcase_17 AC 88 ms
16,124 KB
testcase_18 AC 146 ms
19,196 KB
testcase_19 AC 227 ms
22,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
if n<3
  p n
  exit 0
end

memo=[]
memo[0]=1
memo[1]=0

M=1000000007

for i in 2 .. n
  memo[i] = memo[i-2] + memo[i-3]
  memo[i] %= M
end

p (memo[n]+memo[n-1]+memo[n-2])%M
0