409811: GYM103785 F No Internet IPC!
Description
In IPC, an update has to be installed on all the computers. But alas! There is no internet. The only remaining way is via patch cables - one cable connecting two computers at a time.
The are $$$N$$$ computers in the IPC, and $$$K$$$ patch cables are available. Each computer has exactly one port, so, only upto one patch cable can be connected to a given computer at a time. Initially, the update is installed on the first computer only.
You have to install the update on all the computers. For any two computers connected via patch cables, an update can be transferred and installed in exactly one hour.
You have to compute the minimum amount of time required to install the update in all $$$N$$$ computers.
InputThe first line consists of a single integer $$$T$$$ $$$(1 \leq T \leq 10)$$$ - the number of test cases.
Each of the next $$$T$$$ lines consists of two numbers $$$N (1 \leq N \leq 10^5)$$$ and $$$K (1 \leq K \leq 10^5)$$$.
OutputFor each test case, output a single integer on a new line - the minimum number of hours required to copy the files to all $$$N$$$ computers, assuming $$$K$$$ patch cables are available.
ExampleInput4 8 3 6 6 7 1 1 1Output
4 3 6 0Note
In the first example, there are $$$8$$$ computers and $$$3$$$ cables. First, only $$$1$$$ computer is connected. We connect a patch cable to this computer and after one hour, another computer has received the update, making the total computers done to $$$2$$$. Then, we connect two patch cables, one to each of these computers, installing the update in $$$2$$$ more computers by the end of the second hour. Now, $$$4$$$ computers are done. Now we only have $$$3$$$ patch cables, so we connect them to any of them, and get the updated installed on $$$7$$$ computers total by the end of the third hour. The last computer can be connected in the fourth hour, making our answer equal to $$$4$$$.