結果
| 問題 | No.40 多項式の割り算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-16 22:03:41 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 4,558 ms / 5,000 ms |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 296 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 85,376 KB |
| 最終ジャッジ日時 | 2026-06-05 10:01:54 |
| 合計ジャッジ時間 | 18,571 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
コンパイルメッセージ
Main.rb:1: warning: shebang line ending with \r may cause problems Syntax OK
ソースコード
#!/usr/bin/ruby
def sub(a,b)
m=[a.size,b.size].max
m.times.map{|i|(a[i]||0) - (b[i]||0)}
end
def checkio(exp,div)
c=[]
while div.size<=exp.size
d=exp[-1]/div[-1]
c.push(d)
exp=sub(exp,[0]*(exp.size-div.size)+div.map{|e|e*d})
#assert exp[-1]==0
exp.pop
end
exp.pop() while exp.size>1 && exp[-1]==0
puts exp.size-1
puts exp*' '
end
gets
checkio(gets.split.map(&:to_i),[0,-1,0,1])