题库练习 Divisibility by 2^n
← 上一题 下一题 →

A15374 | Divisibility by 2^n

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given an array of positive integers $a_1, a_2, \ldots, a_n$ .

Make the product of all the numbers in the array (that is, $a_1 \cdot a_2 \cdot \ldots \cdot a_n$ ) divisible by $2^n$ .

You can perform the following operation as many times as you like:

- select an arbitrary index $i$ ( $1 \leq i \leq n$ ) and replace the value $a_i$ with $a_i=a_i \cdot i$ .

You cannot apply the operation repeatedly to a single index. In other words, all selected values of $i$ must be different.

Find the smallest number of operations you need to perform to make the product of all the elements in the array divisible by $2^n$ . Note that such a set of operations does not always exist.

输入格式

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

Then the descriptions of the input data sets follow.

The first line of each test case contains a single integer $n$ ( $1 \leq n \leq 2 \cdot 10^5$ ) — the length of array $a$ .

The second line of each test case contains exactly $n$ integers: $a_1, a_2, \ldots, a_n$ ( $1 \leq a_i \leq 10^9$ ).

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

输出格式

For each test case, print the least number of operations to make the product of all numbers in the array divisible by $2^n$ . If the answer does not exist, print -1.

输入输出样例

输入 #1
6
1
2
2
3 2
3
10 6 11
4
13 17 1 1
5
1 1 12 1 1
6
20 7 14 18 3 5
输出 #1
0
1
1
-1
2
1
C++ 编辑器
输入
输出