結果

問題 No.554 recurrence formula
ユーザー ueyukiueyuki
提出日時 2017-09-22 04:38:08
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 283 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 11,512 KB
実行使用メモリ 19,744 KB
最終ジャッジ日時 2023-08-08 14:14:22
合計ジャッジ時間 11,332 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
19,744 KB
testcase_01 AC 79 ms
15,144 KB
testcase_02 AC 80 ms
15,176 KB
testcase_03 AC 80 ms
15,100 KB
testcase_04 AC 80 ms
15,016 KB
testcase_05 AC 78 ms
15,052 KB
testcase_06 AC 78 ms
15,040 KB
testcase_07 AC 78 ms
15,152 KB
testcase_08 AC 79 ms
15,000 KB
testcase_09 AC 79 ms
15,288 KB
testcase_10 AC 169 ms
15,196 KB
testcase_11 AC 924 ms
15,096 KB
testcase_12 AC 685 ms
15,000 KB
testcase_13 TLE -
testcase_14 AC 928 ms
15,152 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i

a = [0, 1]

2.upto(n) do |i|
  item = 0
  if i % 2 == 0
    1.upto(i-1) do |k|
      (k % 2 == 1) ? item += a[k] : next
    end
  else
    1.upto(i-1) do |k|
      (k % 2 == 0) ? item += a[k] : next
    end
  end
  a << (i * item) % (10 ** 9 + 7)
end

puts a[-1]
0