|
||||||||||
Multiply 2 Divide 2Time Limit: 15000/7500 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 178 Accepted Submission(s): 63 Problem Description $\textbf{Note:There is no dependency between this problem and problem Hack of Multiply 2 Divide 2.}$ Frank_DD has a sequence $a$ of length $n$. For each operation, he selects a number $a_i(1 \le i \le n)$ and changes it to $a_i\cdot 2$ or $\lfloor \frac{a_i}{2} \rfloor$. Frank_DD wants to know the minimum number of operations to change the sequence $a$ to a non-descending sequence. Input The first line of the input contains one integer $T$ $($$1\leq T\leq 5$ $)$ --- the number of test cases. Then $T$ test cases follow. In each test case: The first line contains a single integer $n(1 \leq n \leq 10^5)$ --- the length of sequence $a$. The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ $(1 \leq a_i \leq 10^5)$ --- the sequence $a$. Output For each test case, print a single integer in a single line --- the minimum number of operations to change the sequence $a$ to a non-descending sequence. Sample Input
Sample Output
Hint In the first test case, we can use at least 4 operations to change the sequence $a$ to a non-descending sequence: $a_1=\lfloor \frac{a_1}{2} \rfloor$ $a_5=\lfloor \frac{a_5}{2} \rfloor$ $a_7=a_7 \cdot 2$ $a_7=a_7 \cdot 2$ Source | ||||||||||
|