結果

問題 No.40 多項式の割り算
ユーザー DialBirdDialBird
提出日時 2017-02-13 10:24:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2023-08-28 15:09:00
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,368 KB
testcase_01 AC 77 ms
15,292 KB
testcase_02 AC 78 ms
15,324 KB
testcase_03 AC 77 ms
15,168 KB
testcase_04 AC 81 ms
15,352 KB
testcase_05 AC 82 ms
15,416 KB
testcase_06 AC 83 ms
15,312 KB
testcase_07 AC 82 ms
15,412 KB
testcase_08 AC 78 ms
15,300 KB
testcase_09 AC 79 ms
15,180 KB
testcase_10 AC 81 ms
15,368 KB
testcase_11 AC 80 ms
15,348 KB
testcase_12 AC 79 ms
15,196 KB
testcase_13 AC 80 ms
15,516 KB
testcase_14 AC 80 ms
15,208 KB
testcase_15 AC 80 ms
15,232 KB
testcase_16 AC 81 ms
15,552 KB
testcase_17 AC 79 ms
15,284 KB
testcase_18 AC 82 ms
15,500 KB
testcase_19 AC 82 ms
15,612 KB
testcase_20 AC 82 ms
15,092 KB
testcase_21 AC 80 ms
15,196 KB
testcase_22 AC 79 ms
15,084 KB
testcase_23 AC 80 ms
15,188 KB
testcase_24 AC 80 ms
15,576 KB
testcase_25 AC 76 ms
15,224 KB
testcase_26 AC 77 ms
15,152 KB
testcase_27 AC 77 ms
15,264 KB
testcase_28 AC 76 ms
15,256 KB
testcase_29 AC 77 ms
15,152 KB
testcase_30 AC 77 ms
15,184 KB
testcase_31 AC 76 ms
15,324 KB
testcase_32 AC 77 ms
15,104 KB
testcase_33 AC 78 ms
15,300 KB
testcase_34 AC 77 ms
15,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Solve
  def initialize
    _ = gets.to_i
    @a_list = gets.chomp.split.map(&:to_i)
  end

  def run
    len = @a_list.size
    (len - 1).downto(3) do |i|
      if @a_list[i] != 0
        @a_list[i-2] += @a_list[i]
        @a_list[i] = 0
      end
    end

    puts get_ans_list[0]
    puts get_ans_list[1]
  end

  private

  def get_ans_list
    list = []
    3.downto(0) do |i|
      if (@a_list[i] != 0 && @a_list[i] != nil) || i == 0
        list << i
        list << @a_list[0..i].join(' ')
        break
      end
    end

    list
  end
end

Solve.new.run
0