New update is available. Click here to update.

Cut Logs

Posted: 19 Dec, 2020
Difficulty: Hard


Try Problem

Ninja is a log cutter. He has a ‘K’ number of axes and an infinite amount of logs. But, Ninja has a log cutting stand that has a capacity of ‘N’, which means he can only try to cut at max ‘N’ logs in one go. All the axes are exactly the same and can cut up to some logs in one go. If we try to cut more logs than its capacity the axe will break.

To improve efficiency, Ninja wants to know how many logs he can cut with an axe in one go without breaking it. But, he wants to know this is the minimum number of moves and in the allotted number of axes.

Can you calculate the minimum number of moves in which Ninja can know the limit of axes?

Some points to notice about axes are:
1. An axe that is used to cut a lesser or equal number of logs than its limit can be used again.

2. An axe that is used to cut more logs than its limit will be broken. Thus, it cannot be used again.

3. All the axes have the same limit of cutting logs until broken.

4. An axe may also cut N logs or may not even cut a single log.


Let the number of axes (K) be 2 & the capacity of the log cutting stand (N) be 6.


From the above example, we can see that the maximum number of moves is 3 for 2 axes and a capacity of 6 logs.
Input format:
The first line of input contains an integer ‘T’ denoting the number of queries or test cases. 

The first and only line of each input consists of 2 space-separated integers ‘K’ and ‘N’ denoting the number of axes and the capacity of log cutting stand simultaneously.
Output format:
For each test case, print the minimum number of moves required to know the limit of the axe.

Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
Follow Up
Can you solve this in the worst-case time complexity of N ^ (1/3)
1 <= T <= 10
1 <= K <= 100
1 <= N <= 10000