NUMGUESS - Guess the Number

no tags 

You play a game with Bob: He thinks of a number from a given range and you try to guess it. If you're right, you win. If you're wrong, he tells you if the number is too high or too low and you get to try again. Try to win in the lowest possible number of guesses! Beware: Bob isn't exactly known for playing fair.

Input/Output

First line Bob tells you consists of two integers a and b, 0<=a<=b<=10000. It is the range in which Bob's number lies. On every turn, you should print a number -- your guess. Every time Bob answers with one of: "LOW", "HIGH", "WIN", meaning your number is too low, too high or you've just won.

Example

Bob: 4 30
You: 3
Bob: LOW
You: 9
Bob: HIGH
You: 8
Bob: WIN

Remark: Program should clear the output buffer after printing each line. It can be done using fflush(stdout) command or you can set the proper type of buffering at the beginning of the execution - setlinebuf(stdout).


hide comments
kamran siddique: 2016-04-08 10:05:56

Don't Declare any guess variable inside the loop !!!! what a bug yaaaaaaarrrrr.

Neeraj Singh Aithani: 2015-09-26 18:52:31

I am getting TLE :( I Have used binary search any idea ???


Added by:Tomek
Date:2007-08-06
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:first SPOJ "interactive" problem