P12874 [HackerEarth] roy and coding contest
普及
题目描述

Roy is going to organize Finals of Coding Contest in his college's computer labs. According to the rules of contest, problem statements will be available on each computer as pdf file.

Now there are N number of computers and only one of them has the pdf file. Roy has collected M number of pendrives from his friends. Copying pdf from computer to pendrive or from pendrive to computer takes exactly 1 minute. Roy has to copy pdf to all N computers in minimum (optimal) time possible. You are to find this minimum time. Please see Sample Test Explanation for clarity.

Input:

First line will contain integer T - number of test cases.

Next T lines each will contain two space separated integers, N - number of computers, M - number of pendrives.

Output:

Print the minimum time (in minutes) for each test case in a new line.

Constraints:

1 ≤ T ≤ 10000

1 ≤ N,M ≤ 1000000000 (10^9)

SAMPLE INPUT
1
10 3SAMPLE OUTPUT
5Explanation

Just for the sake of understanding, let us number computers from 1 to 10 and pendrives from 1 to 3. Initially only 1st computer has the pdf.

1st minute: Roy copies the pdf from 1st computer to 1st pendrive, so 1 computer and 1 pendrive has the pdf
2nd minute: He copies the pdf from 1st pendrive to 2nd computer and alongside he copies pdf from 1st computer to 2nd pendrive.
3rd minute: Now he has two pendrives with pdf, so he copies the pdf to 3rd and 4th computer using 1st and 2nd pendrive. Alongside he already copied pdf to 1st and 2nd computer and has one pendrive blank. So he copies pdf into 3rd pendrive using any of the 1st or 2nd computer.
4th minute: Now first 4 computers are done and we have pdf in all 3 pendrives. So he simply copies pdf into 5th, 6th and 7th computer using three pendrive respectively.
5th minute: He copies the pdf into 8th, 9th and 10th computers using three pendrives respectively.

输入格式

见题面

输出格式

见题面

样例输入
100 891404 114455 610316 163967 749122 997845 190654 103521 603077 94067 155081 68879 868235 163648 892190 750264 81323 808101 249009 507040 546018 794692 467431 985208 708086 648973 368128 291957 737517 66792 235797 953712 584949 880076 493806 588204 194761 761192 529058 563607 879968 305895 384874 664845 736270 220869 916956 49314 964869 390631 915511 342385 478022 370075 642218 697590 882691 454927 491614 484816 387608 732907 672348 859254 801800 505193 475773 98349 27707 218358 275982 659756 302999 807607 682822 229513 420118 180598 744677 82792 324350 524684 485710 556272 171399 950738 769499 476051 205648 133380 509429 809655 550243 959999 800156 758304 32567 815936 943481 430222 996476 427841 905795 872677 678289 636672 167782 704148 585279 254249 234019 231834 430682 112915 757301 521429 506321 532726 739104 384076 351108 269146 915664 916595 601796 269825 355434 159499 775321 207326 313781 425518 326821 977984 587688 971389 332018 487024 288614 452405 604881 582629 89598 755504 132280 844551 713317 621133 329286 703877 260869 834726 217595 130331 100212 676657 951252 221553 947003 320652 313553 454802 736748 348367 571642 92773 748332 166816 79837 583575 862121 580885 100232 274572 734160 410056 340794 76914 238957 949296 614384 941385 556405 323324 344287 94998 267759 761053 198508 735360 97937 97150 582772 48571 55331 305704 467294 398266 946237 675853
样例输出
25 22 21 19 24 19 23 21 18 19 21 20 21 20 28 19 21 20 19 21 22 20 22 35 22 22 20 21 21 20 20 21 21 22 16 20 20 21 20 26 20 20 19 21 19 20 21 21 16 21 22 21 21 19 21 19 21 21 20 21 20 21 21 20 22 20 20 21 20 20 21 18 19 21 20 19 19 18 23 22 20 21 23 22 18 21 18 21 21 19 21 21 21 20 19 18 28 17 20 21