How to solve the HDU 1562 Guess the number problem efficiently?