Aryabhata's number

0

0 votes
Problem

You have two positive integers x and y.

You can perform two kinds of operations:

x=x/y (replace x with the integer part of the division between x and y)

y (increase y by 1)

Find the minimum number of operations required to make x=0.

 

Input Format:

The first line contains a single integer t — the number of test cases.

The only line of the description of each test case contains two integers x,y.

Output Format:

For each test case, print a single integer: the minimum number of operations required to make x=0.

 

Constraints:

1t1001x,y109

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

In the first test case, one of the optimal solutions is:

Divide x by y. After this operation x = 4 and y = 2.

Divide x by y. After this operation x = 2 and y = 2.

Increase y. After this operation x = 2 and y = 3.

Divide x by y. After this operation x = 0  and y = 3.

Editor Image

?