$|=1; $a=0; $b=1001; while($a<$b-1){ $c=$a+$b>>1; print"? $c\n"; if(<>=~out){ ++$c; print"? $c\n"; if(<>=~out){ $b=$c-1; }else{ $a=$c; } }else{ $a=$c; } } print"! $a\n"