結果
| 問題 |
No.40 多項式の割り算
|
| コンテスト | |
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-07-17 11:12:29 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 544 bytes |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 103,528 KB |
| 最終ジャッジ日時 | 2024-10-15 15:15:51 |
| 合計ジャッジ時間 | 13,596 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 TLE * 1 -- * 28 |
コンパイルメッセージ
Main.rb:23: warning: assigned but unused variable - d Syntax OK
ソースコード
require 'pp'
def divide(poly, div, q)
c = poly[-1] / div[-1]
q << c
_poly = []
_div = div.clone
while _div.length < poly.length
_div.unshift(0)
end
poly.length.times{|d|
_poly[d] = poly[d] - c * _div[d]
}
while _poly[-1] == 0
_poly.pop()
end
return [_poly, q]
end
d = gets.to_i
poly = gets.strip.split.map{|e| e.to_i}
div = [0, -1, 0, 1]
q = []
while div.length <= poly.length
poly, q = divide(poly, div, q)
end
if poly.empty?
puts 0
puts 0
else
puts (poly.length - 1)
puts poly.join(' ')
end
d_nishiyama85