fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: isize = n.trim().parse().unwrap(); let mut lower = 1; println!("? {}", lower); let mut lval = String::new(); std::io::stdin().read_line(&mut lval).ok(); let lval: isize = lval.trim().parse().unwrap(); let ldiff = 2 * lval - lower; let mut upper = n-1; println!("? {}", upper); let mut uval = String::new(); std::io::stdin().read_line(&mut uval).ok(); let uval: isize = uval.trim().parse().unwrap(); let udiff = 2 * uval - upper; if ldiff == udiff { println!("! {} {}", 2, upper); return; } while upper > lower { let middle = (upper + lower) / 2; println!("? {}", middle); let mut mval = String::new(); std::io::stdin().read_line(&mut mval).ok(); let mval: isize = mval.trim().parse().unwrap(); let mdiff = 2 * mval - middle; if mdiff == 0 { upper = middle; lower = middle; break; } else if mdiff * ldiff > 0 { lower = middle + 1; } else { upper = middle; } } if upper >= n / 2 { println!("! {} {}", 1, upper); } else { println!("! {} {}", upper+1, n); } }