Guess the Number
An interactive problemI'm thinking of a number between 1 and 2×109, inclusive.
Now it will be your job to try to find my number!
To guess a number, just print it out. See the wiki for instructions on flushing output in your language; you must do this after every guess you print.
I will output something back: "Higher" if your number is too low, or "Lower"
if your number is too high.
I will output "OK" if you guessed correctly! Your program should stop at this point.
Your guessing algorithm must be optimal—you must take less than 32 guesses.
Sample session
You: 10 Me: Lower You: 8 Me: Higher You: 9 Me: OK
All Submissions
Best Solutions
Point Value: 5
Time Limit: 1.00s
Memory Limit: 16M
Added: Jan 18, 2009
Languages Allowed:
Comments (Search)
Otherwise, the interactive program's output just gets dumped.
I pretty sure its not the size of my numbers, but maybe its cause my codes somewhat inefficient?
Instead of using b to control ceil/floor, try saving the previous guess.
Sometimes it's necessary, sometimes it's not - I don't really know.
Anyway, your program doesn't seem to need it.
The problem is that your numbers aren't big enough (it goes up to two billion)
Also, the judge waits for your program to finish because it readln;s at the end - so you have all TLEs (even though you still get 40/50)