|
||||||||||
K. Three OperationsTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 386 Accepted Submission(s): 198 Problem Description Given three integers $x, a, b$. You can do the following three operations several times: - set $x$ to $x - 1$; - set $x$ to $\lfloor \dfrac{x+a}{2} \rfloor$; - set $x$ to $\lfloor \sqrt{x+b} \rfloor$. Calculate the smallest number of operations to set $x$ to $0$. Input The input consists of multiple test cases. The first line contains a single integer $T$ ($1 \le T \le 2 \times 10 ^ 4$) - the number of test cases. Description of the test cases follows. The first line of each test case contains three integers $x, a, b$ ($0\leq x, a, b \leq 10 ^ {18}$). Output For each test case, print one integer - the smallest number of operations to set $x$ to $0$. Sample Input
Sample Output
Source | ||||||||||
|