$>.sync = true def query(n) puts"? #{n}" # s = n >= N ? "1\n" : "0\n" !gets[?0] end puts"! #{(1..10**9).bsearch{|i| query(i) }}"