結果

問題 No.40 多項式の割り算
ユーザー d_nishiyama85d_nishiyama85
提出日時 2016-07-17 11:31:20
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 539 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 80,896 KB
最終ジャッジ日時 2024-04-23 14:59:32
合計ジャッジ時間 51,504 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
12,544 KB
testcase_01 AC 96 ms
12,416 KB
testcase_02 AC 96 ms
12,288 KB
testcase_03 AC 96 ms
12,288 KB
testcase_04 AC 1,652 ms
79,104 KB
testcase_05 AC 2,673 ms
80,384 KB
testcase_06 AC 4,599 ms
77,016 KB
testcase_07 AC 4,990 ms
79,360 KB
testcase_08 AC 107 ms
12,672 KB
testcase_09 AC 2,264 ms
77,056 KB
testcase_10 AC 4,032 ms
77,228 KB
testcase_11 AC 1,412 ms
80,896 KB
testcase_12 AC 601 ms
37,760 KB
testcase_13 AC 3,940 ms
76,760 KB
testcase_14 AC 1,639 ms
78,848 KB
testcase_15 AC 1,608 ms
78,720 KB
testcase_16 AC 3,977 ms
76,828 KB
testcase_17 AC 385 ms
28,416 KB
testcase_18 AC 3,611 ms
74,780 KB
testcase_19 TLE -
testcase_20 AC 1,108 ms
77,696 KB
testcase_21 AC 292 ms
23,808 KB
testcase_22 AC 233 ms
19,200 KB
testcase_23 AC 1,055 ms
72,576 KB
testcase_24 AC 2,617 ms
79,872 KB
testcase_25 AC 95 ms
12,416 KB
testcase_26 AC 98 ms
12,288 KB
testcase_27 AC 95 ms
12,288 KB
testcase_28 AC 98 ms
12,416 KB
testcase_29 AC 98 ms
12,544 KB
testcase_30 AC 96 ms
12,416 KB
testcase_31 AC 95 ms
12,288 KB
testcase_32 AC 96 ms
12,544 KB
testcase_33 AC 94 ms
12,544 KB
testcase_34 AC 95 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: assigned but unused variable - d
Syntax OK

ソースコード

diff #

require 'pp'

def divide(poly, div)
  c = poly[-1] / div[-1]
  _poly = []

  len = poly.length
  len.times{|d|
    if len - d < div.length
      _poly[d] = poly[d] - c * div[div.length - (len - d)]
    else
      _poly[d] = poly[d]
    end
  }
  while _poly[-1] == 0
    _poly.pop()
  end

  return _poly
end

d = gets.to_i
poly = gets.strip.split.map{|e| e.to_i}

div = [0, -1, 0, 1]

while div.length <= poly.length
  poly = divide(poly, div)
end

if poly.empty?
  puts 0
  puts 0
else
  puts (poly.length - 1)
  puts poly.join(' ')
end
0