#P7494. 三遣救援
三遣救援
Description
One morning, Muro found that a piece of cake he had secretly kept was eaten! He immediately guessed that one of the pigs had eaten the cake, so he rushed to the pigsty to find that pig and punish it.
There are pigs in the pigsty, numbered with integers from to . Except for the pig that ate the cake, all other pigs have the same weight, and the pig that ate the cake is slightly heavier than the others (you may assume the pigs were originally , and the one that ate the cake is ). Muro cannot tell by sight which pig ate the cake.
Fortunately, Muro has a balance scale. He can drive pigs onto the two sides of the scale to compare which side is heavier. However, this scale is not very large: each side can hold at most pigs, otherwise the scale will be damaged and become unusable (the pig that ate the cake will not reduce the number of pigs that can be placed on one side, i.e., whether or not a pig ate the cake, each side can still hold at most pigs).
Muro does not want to spend too much time, so he wants to know, under the condition that the scale is not damaged, at least how many weighings are needed to guarantee finding the pig that ate the cake. Please compute this number.
Input Format
One line with two positive integers .
Output Format
One line with one positive integer, the answer.
4 5
2
13 6
3
8 2
3
114 514
5
19198 10
962
Hint
Explanation for Sample 1:
Muro first puts pig and pig onto the two sides of the scale respectively, then puts pig and pig onto the two sides respectively. In this way, he can definitely find the pig that ate the cake, and the number of weighings is . Obviously, using the scale only once cannot guarantee finding the pig that ate the cake.
Explanation for Sample 3:
Each side of the scale can hold at most pigs, so at least weighings are needed to guarantee finding it.
Constraints
This problem uses bundled testdata.
- Subtask 1 ( ): .
- Subtask 2 ( ): .
- Subtask 3 ( ): .
- Subtask 4 ( ): no special constraints.
For all testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号