1485A.md (1227B)
1 Source: https://codeforces.com/problemset/problem/1485/A 2 3 A. Add and Divide 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You have two positive integers $a$ and $b$. 22 23 You can perform two kinds of operations: 24 25 * $a = \lfloor \frac{a}{b} \rfloor$ (replace $a$ with the integer part of the division between $a$ and $b$) 26 * $b=b+1$ (increase $b$ by $1$) 27 28 Find the minimum number of operations required to make $a=0$. 29 30 Input 31 32 The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. 33 34 The only line of the description of each test case contains two integers $a$, $b$ ($1 \le a,b \le 10^9$). 35 36 Output 37 38 For each test case, print a single integer: the minimum number of operations required to make $a=0$. 39 40 Example 41 42 Input 43 44 ``` 45 6 46 9 2 47 1337 1 48 1 1 49 50000000 4 50 991026972 997 51 1234 5678 52 ``` 53 54 Output 55 56 ``` 57 4 58 9 59 2 60 12 61 3 62 1 63 ``` 64 65 Note 66 67 In the first test case, one of the optimal solutions is: 68 69 1. Divide $a$ by $b$. After this operation $a = 4$ and $b = 2$. 70 2. Divide $a$ by $b$. After this operation $a = 2$ and $b = 2$. 71 3. Increase $b$. After this operation $a = 2$ and $b = 3$. 72 4. Divide $a$ by $b$. After this operation $a = 0$ and $b = 3$.