CF1762A.Divide and Conquer

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Divide and Conquer

An array bb is good if the sum of elements of bb is even.

You are given an array aa consisting of nn positive integers. In one operation, you can select an index ii and change ai:=ai2a_i := \lfloor \frac{a_i}{2} \rfloor. ^\dagger

Find the minimum number of operations (possibly 00) needed to make aa good. It can be proven that it is always possible to make aa good.

^\dagger x\lfloor x \rfloor denotes the floor function — the largest integer less than or equal to xx. For example, 2.7=2\lfloor 2.7 \rfloor = 2, π=3\lfloor \pi \rfloor = 3 and 5=5\lfloor 5 \rfloor =5.

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t10001 \leq t \leq 1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (1n501 \leq n \leq 50) — the length of the array aa.

The second line of each test case contains nn space-separated integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1061 \leq a_i \leq 10^6) — representing the array aa.

Do note that the sum of nn over all test cases is not bounded.

Output

For each test case, output the minimum number of operations needed to make aa good.

Note

In the first test case, array aa is already good.

In the second test case, we can perform on index 22 twice. After the first operation, array aa becomes [7,2][7,2]. After performing on index 22 again, aa becomes [7,1][7,1], which is good. It can be proved that it is not possible to make aa good in less number of operations.

In the third test case, aa becomes [0,2,4][0,2,4] if we perform the operation on index 11 once. As [0,2,4][0,2,4] is good, answer is 11.

In the fourth test case, we need to perform the operation on index 11 four times. After all operations, aa becomes [0][0]. It can be proved that it is not possible to make aa good in less number of operations.

Samples

4
4
1 1 1 1
2
7 4
3
1 2 4
1
15
0
2
1
4

在线编程 IDE

建议全屏模式获得最佳体验