CCO '26 Lab Session 2 Practice Problem 2 - Guess The Number 2
View as PDFI am thinking of an integer between
and
.
You can guess up to 40 numbers to discover
.
Each time, I will tell you if your guess is
too low, too high, or just right.
However, the game ends in your loss if I respond too low 10 or more times.
Can you determine ?
Input Specification
The first line of input will contain a single integer, (
).
Output Specification
For each guess, output an integer , (
).
Interaction
The judge will start by printing the integer .
You may make up to 40 guesses to the judge.
For each guess, output the guessed number on a new line, and flush standard output.
The judge will respond with either
too low, too high, or just right.
- Your program will be judged as correct if the judge outputs
just right. - If you exceed the allowed number of queries, the judge will output
query limit exceededand your program will receive the verdictWrong Answer. - If you exceed the allowed number of
too lowresponses, the judge will outputtoo many too lowand your program will receive the verdictWrong Answer.
In all cases, your program should terminate immediately.
Sample Interaction
>>> denotes your output; don't actually print this out.
5
>>>1
too low
>>>2
too low
>>>4
too high
>>>3
just right
Notes
The grader is adaptive, i.e. it will attempt to screw you over.
Problem Source: 2006 Chinese Winter Training Camp Report.
Comments
Data has been buffed and all submissions rejudged.