#P16806. [蓝桥杯 2026 国 Python A] 糖分极限
[蓝桥杯 2026 国 Python A] 糖分极限
Problem Description
Programmer Xiao Lan needs to refactor a complex project tonight. Because the workload is very intense, he must consume sugar to replenish energy and keep his brain running at high speed.
However, according to the medical checkup report at the beginning of the year, Xiao Lan’s sugar tolerance limit is grams. Once the sugar in his body exceeds this limit, he will instantly fall asleep due to high blood sugar.
At the beginning, the sugar in Xiao Lan’s body is grams.
The company has two kinds of desserts with unlimited supply:
- Donut: each time he eats one, the sugar in his body increases by grams.
- Iced cola: each time he drinks one can, the sugar in his body increases by grams.
To safely take in more energy, during the whole refactoring process, Xiao Lan may do jumping jacks to consume sugar (at most once). This immediately halves the current sugar in his body. If the value after halving is not an integer, discard the fractional part (i.e., take the floor; for example, grams becomes grams after halving).
During the entire sequence of operations, at any moment, the sugar in Xiao Lan’s body must not exceed the tolerance limit grams.
Now please help Xiao Lan compute: under the safety restriction above, what is the maximum number of grams of sugar he can reach in his body?
Input Format
One line contains three positive integers , , and separated by spaces, representing Xiao Lan’s sugar tolerance limit, the sugar increase from eating one donut, and the sugar increase from drinking one can of iced cola (unit: grams).
Output Format
Output one integer, representing the maximum sugar level (in grams) that Xiao Lan can reach within the safe range.
8 5 6
8
Hint
Sample Explanation
Xiao Lan can do the following operations:
- Eat one donut, and the sugar in his body becomes grams.
- Do jumping jacks once, and the sugar in his body is instantly halved to grams.
- Drink one can of iced cola, and the sugar in his body increases by grams, reaching grams.
At this point, it exactly reaches the tolerance limit and cannot be increased further, so output .
Constraints
For of the testdata, .
For all testdata, , .
Translated by ChatGPT 5