STDIN.sync = true STDOUT.sync = true puts "? 0 0" d1 = gets.to_i puts "? 0 100" d2 = gets.to_i (0 .. 100).each do |x| (0 .. 100).each do |y| next unless x**2 + y**2 == d1 and x**2 + (y - 100)**2 == d2 puts "! %d %d" % [x, y] exit end end