結果

問題 No.40 多項式の割り算
ユーザー tshigtshig
提出日時 2016-08-19 17:50:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 229 ms / 5,000 ms
コード長 471 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 84,224 KB
最終ジャッジ日時 2024-04-25 08:06:10
合計ジャッジ時間 5,584 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,160 KB
testcase_01 AC 75 ms
12,160 KB
testcase_02 AC 78 ms
12,160 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 150 ms
83,584 KB
testcase_05 AC 181 ms
83,456 KB
testcase_06 AC 218 ms
84,224 KB
testcase_07 AC 224 ms
84,224 KB
testcase_08 AC 77 ms
12,416 KB
testcase_09 AC 156 ms
83,584 KB
testcase_10 AC 219 ms
83,840 KB
testcase_11 AC 140 ms
81,280 KB
testcase_12 AC 98 ms
30,592 KB
testcase_13 AC 212 ms
83,968 KB
testcase_14 AC 143 ms
83,584 KB
testcase_15 AC 148 ms
83,584 KB
testcase_16 AC 205 ms
84,096 KB
testcase_17 AC 91 ms
26,880 KB
testcase_18 AC 188 ms
83,712 KB
testcase_19 AC 229 ms
84,096 KB
testcase_20 AC 127 ms
64,512 KB
testcase_21 AC 86 ms
18,432 KB
testcase_22 AC 85 ms
18,048 KB
testcase_23 AC 124 ms
60,800 KB
testcase_24 AC 171 ms
83,456 KB
testcase_25 AC 77 ms
12,160 KB
testcase_26 AC 78 ms
12,160 KB
testcase_27 AC 76 ms
12,160 KB
testcase_28 AC 78 ms
12,160 KB
testcase_29 AC 88 ms
12,160 KB
testcase_30 AC 79 ms
12,160 KB
testcase_31 AC 78 ms
12,288 KB
testcase_32 AC 78 ms
12,288 KB
testcase_33 AC 74 ms
12,160 KB
testcase_34 AC 77 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0040
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @d = args.shift.first.to_i
    @as = args.shift.map(&:to_i)
  end

  def run
    as = @as.reverse
    until as.size <= 3
      a = as.first
      as[0] -= a
      as[2] += a
      as = as.drop_while { |a| a == 0 }
    end

    if as.empty?
      [0, 0]
    else
      [as.size - 1, as.reverse.join(' ')]
    end
  end
end

puts Calc0040.new(STDIN.readlines).run if __FILE__ == $0
0