結果
| 問題 | No.40 多項式の割り算 |
| コンテスト | |
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-07-17 11:31:20 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 539 bytes |
| 記録 | |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 8,192 KB |
| 実行使用メモリ | 81,792 KB |
| 最終ジャッジ日時 | 2025-02-21 06:28:33 |
| 合計ジャッジ時間 | 52,141 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 TLE * 2 |
コンパイルメッセージ
Main.rb:22: warning: assigned but unused variable - d Syntax OK
ソースコード
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
d_nishiyama85