Counterfeit Coin

5

1 votes
Easy
Problem

You are given a balance with K  pans. When the weights on all the pans are equal, the balance doesn’t tip. If the weight placed on a pan is greater than the rest, the balance tips towards that side. If there exist multiple such pans, the balance tips towards one of those pans randomly with equal probability. Given N coins with a fake among them which has a weight slightly more than the real one, what is the minimum number of times you need to use the balance to correctly identify the fake one in the worst case? Use of balance consists of placing a certain number of coins on each pan, checking the state of the balance and then removing them all.

Input format

Two space-separated integers N and K

Output format

Output a single number, which is the number of times the balance is needed to be used in the worst case.

Constraints

1KN109

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Split the coins into piles of 7 each and weight them once. The balance tips. Take the pile towards which the balanced tipped to and weight it again by splitting it into piles of 1 coin each. This would give you the fake coin in 2 tries.

Editor Image

?