結果

問題 No.40 多項式の割り算
ユーザー siman
提出日時 2015-04-02 00:11:07
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-07-03 23:12:48
合計ジャッジ時間 4,885 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class A
  def initialize
    d = gets.chomp.to_i
    a = gets.chomp.split(' ').map(&:to_i).reverse

    0.upto(d-3) do |num|
      a[num+2] += a[num]
      a[num] = 0
    end

    if a.index{|i| i != 0}
      puts d - a.index{|i| i != 0}
    else
      puts 0
    end
    #a.delete(0)
    puts encode(a).join(' ')
  end

  def encode(answer)
    index = answer.index{|n| n > 0}

    index && answer[index.to_i..-1].reverse || [0]
  end
end

A.new
0