def calc(x) (1..100000).bsearch {|k| x < k*(k+1)/2 }-1 end def bye(x) p x exit end n = gets.to_i lis = [] 1.upto(4500) do |k| lis << k*(k+1)/2 end bye 1 if lis.bsearch{|x| n <=> x} lis.each do |x| bye 2 if lis.bsearch{|y| n <=> x+y} end bye 3