Time limit: 1s
Memory limit: 256MB
Input:
Output:
chose a random positive integer () and wants you to guess it.
Initially, he will tell you the sum of digits of . Then, you can ask to decrease by any positive integer . If , you lose. Otherwise, and you will be told the sum of digits of the new number.
says that you can ask him to decrease at most times.
Task
You need to implement the function long long guess(int s)
that returns the hidden number that was chosen at the beginning, knowing the initial sum of digits.
You can call a function int ask(long long y)
that will decrease by and return the new sum of digits.
Example
guess
is called withask(1)
returns and nowask(3)
returns and nowask(10)
will now end the game and you lose