def candidate(p, q, d) ts = [] (0..100).each do |y| (0..100).each do |x| if ((p - x) ** 2 + (q - y) ** 2) == d then ts.push([x, y]) end end end return ts end def intersection(s, t) u = [] s.each do |x| u.push(x) if t.include?(x) end return u end def get_candidate(p, q) puts "? #{p} #{q}" STDOUT.flush d = gets.chomp.to_i return candidate(p, q, d) end def main(argv) p = 0 q = 0 ts1 = get_candidate(p, q) p = 0 q = 100 ts2 = get_candidate(p, q) ts = intersection(ts1, ts2) p = ts[0][0] q = ts[0][1] puts "! #{p} #{q}" STDOUT.flush end main(ARGV) if self.to_s == 'main'