luogu#P4862. 猜数
猜数
Background
Iris and Beryl are playing a number guessing game.
Problem Description
The game works as follows: given a positive integer , Iris chooses a number from .
Then, Iris must answer Beryl’s questions truthfully. Each question is of the form: “Is an element of set ?” where .
If Iris answers “Yes”, then Beryl must give Iris yuan; otherwise, Beryl must give Iris yuan. (The testdata guarantees .)
How much money does Beryl need to prepare at least, to be sure that she can determine the number in Iris’s mind?
Input Format
The first line contains two positive integers and , and the number of test cases .
The next lines each contain a given positive integer , with the meaning as described above.
Output Format
Output lines. For each test case, output the minimum amount of money Beryl needs to prepare.
2 1 2
3
6
3
5
5 3 1
3
8
Hint
[Explanation for the 1st test case of Sample 1]
Beryl first asks about the set . If the answer is “Yes”, then Iris’s number is confirmed to be , and Beryl needs yuan. If the answer is “No”, then Beryl asks about the set . Clearly, in the worst case she needs to spend another yuan, for a total of yuan, so the answer is yuan.
[Constraints]
| Test Point ID | , | ||
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | |||
| 8 | , | ||
| 9 | |||
| 10 |
Translated by ChatGPT 5