- 792 名前:デフォルトの名無しさん mailto:sage [2022/09/09(金) 23:46:43.88 ID:3788iROh.net]
- >>751 ruby
https://ideone.com/hBHe51 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)
|

|