Codeforces Round 796 (Div. 2)
B
Patchouli's Magical Talisman
Codeforces
800
原题
← AC →
翻译中…

She is skilled in all kinds of magics, and is keen on inventing new one.—Perfect Memento in Strict Sense

翻译中…

Patchouli is making a magical talisman. She initially has $n$ magical tokens. Their magical power can be represented with positive integers $a_1, a_2, \ldots, a_n$.

翻译中…

Patchouli may perform the following two operations on the tokens.

翻译中…
  • Fusion: Patchouli chooses two tokens, removes them, and creates a new token with magical power equal to the sum of the two chosen tokens.
  • Reduction: Patchouli chooses a token with an even value of magical power $x$, removes it and creates a new token with magical power equal to $\frac{x}{2}$.
翻译中…

Tokens are more effective when their magical powers are odd values. Please help Patchouli to find the minimum number of operations she needs to make magical powers of all tokens odd values.

翻译中…

Input

翻译中…

Each test contains multiple test cases.

翻译中…

The first line contains a single integer $t$ ($1 \leq t \leq 10^3$) — the number of test cases. The description of the test cases follows.

翻译中…

For each test case, the first line contains one integer $n$ ($1 \leq n\leq 2\cdot 10^5$) — the initial number of tokens.

翻译中…

The second line contains $n$ intergers $a_1,a_2,\ldots,a_n$ ($1 \leq a_i \leq 10^9$) — the initial magical power of the $n$ tokens.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, print a single integer — the minimum number of operations Patchouli needs to make all tokens have an odd value of magical power.

翻译中…

It can be shown that under such restrictions the required sequence of operations exists.

翻译中…

Note

翻译中…

Test case 1:

翻译中…

$a$ consists solely of odd numbers initially.

翻译中…

Test case 2:

翻译中…

Choose the tokens with magical power of $1$ and $2$ and perform Fusion. Now $a=[1,3]$, both are odd numbers.

翻译中…

Test case 3:

翻译中…

Choose the tokens with magical power of $2$ and $8$ and perform Fusion. Now $a=[4,10]$.

翻译中…

Choose the token with magical power of $10$ and perform Reduction. Now $a=[4,5]$.

翻译中…

Choose the tokens with magical power of $4$ and $5$ and perform Fusion. Now $a=[9]$, and $9$ is an odd number.

翻译中…

It can be shown that you can not make all the magical powers odd numbers in less than $3$ moves, so the answer is $3$.

翻译中…

样例

Input #1
4
2
1 9
3
1 1 2
3
2 4 8
3
1049600 33792 1280
Output #1
0
1
3
10
InputCopy OutputCopy
题目信息
题号
1688B
时间限制
1 s
内存限制
256 MB
标签
位运算
构造
贪心
排序

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