package main import ( "fmt" ) import ( "bufio" "os" "strconv" ) func main() { // screenBuffer := bytes.NewBuffer(nil) // screenWriter := bufio.NewWriterSize(screenBuffer, 8192) A := 0 B := pow(10, 9) + 1 for B-A > 1 { c := (A + B) / 2 fmt.Print("? ") fmt.Println(c) ans := nextInt() if ans == 1 { A = c }else { B = c } } fmt.Print("! ") fmt.Println(A) } var s = bufio.NewScanner(os.Stdin) func next() string { s.Split(bufio.ScanWords) s.Scan() return s.Text() } func nextLine() string { s.Split(bufio.ScanLines) s.Scan() return s.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } func nextLong() int64 { i, e := strconv.ParseInt(next(), 10, 64) if e != nil { panic(e) } return i } //aのb乗をします O(log b) func pow(a int, b int) int { total := 1 tmp := a for b > 0 { if b%2 == 1 { total*=tmp } b/=2 tmp*=tmp } return total }