Codeforces Round 701 (Div. 2)
A
Add and Divide
Codeforces
1000
原题
←B →
翻译中…

You have two positive integers $a$ and $b$.

翻译中…

You can perform two kinds of operations:

翻译中…
  • $a = \lfloor \frac{a}{b} \rfloor$ (replace $a$ with the integer part of the division between $a$ and $b$)
  • $b=b+1$ (increase $b$ by $1$)
翻译中…

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

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases.

翻译中…

The only line of the description of each test case contains two integers $a$, $b$ ($1 \le a,b \le 10^9$).

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…
  1. Divide $a$ by $b$. After this operation $a = 4$ and $b = 2$.
  2. Divide $a$ by $b$. After this operation $a = 2$ and $b = 2$.
  3. Increase $b$. After this operation $a = 2$ and $b = 3$.
  4. Divide $a$ by $b$. After this operation $a = 0$ and $b = 3$.
翻译中…

样例

Input #1
6
9 2
1337 1
1 1
50000000 4
991026972 997
1234 5678
Output #1
4
9
2
12
3
1
InputCopy OutputCopy
题目信息
题号
1485A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。