#P7494. Identifying the Cake-Stealing Pig
Identifying the Cake-Stealing Pig
Identifying the Cake-Stealing Pig
One morning, Muro discovered that a cake he had stored privately was partly eaten! He immediately suspected that one pig was responsible and rushed to the pigpen to identify and punish the culprit.
In the pigpen there are \(n\) pigs, numbered from \(1\) to \(n\). All pigs have the same weight except for the one that stole the cake, which is slightly heavier (for example, if a normal pig weighs \(5\,\mathrm{kg}\), the culprit weighs \(5.1\,\mathrm{kg}\)). Muro cannot tell the heavy pig apart by looking.
Fortunately, Muro has a balance scale that compares the weights of pigs placed on its two pans. However, the scale is delicate: each pan can hold at most \(m\) pigs, otherwise it will be damaged. (Note that even if the heavy pig is placed on a pan, it does not change the maximum number of pigs allowed on that pan.)
Under these conditions, Muro wants to know the minimum number of weighings required to guarantee that he can identify the cake-stealing pig without damaging the scale.
Your task is to compute that minimum number.
inputFormat
The input consists of a single line containing two integers \(n\) and \(m\) separated by a space, where \(n\) is the number of pigs and \(m\) is the maximum number of pigs allowed on each pan of the scale.
\(1 \le n, m \le 10^9\)
outputFormat
Output a single integer representing the minimum number of weighings required to identify the cake‐stealing pig.
sample
5 1
2