22/09/09 23:46:43.88 3788iROh.net
>>751 ruby
URLリンク(ideone.com)
def f(as, bs)
c = as.combination(2).map(&:sort).to_a.uniq.map {|x, y| [x * y, x, y]}.sort_by(&:first).each_cons(2)
bs.map do |b|
d = c.find {|e, f| e[0] < b && b <= f[0]}
"#{b}:#{d ? d[1][1..2].join(',') : 'error'}"
end
end
a = [17, 3, 3, 1, 6, 13, 11, 17, 2, 5, 7, 18, 16, 5, 8, 6, 5, 1, 11, 1]
b = [390, 240, 37, 396, 198, 99, 242, 53, 329, 202]
puts f(a, b)