CF1762A.Divide and Conquer
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An array b is good if the sum of elements of b is even.
You are given an array a consisting of n positive integers. In one operation, you can select an index i and change ai:=⌊2ai⌋ . †
Find the minimum number of operations (possibly 0 ) needed to make a good. It can be proven that it is always possible to make a good.
† ⌊x⌋ denotes the floor function — the largest integer less than or equal to x . For example, ⌊2.7⌋=2 , ⌊π⌋=3 and ⌊5⌋=5 .
输入格式
Each test contains multiple test cases. The first line contains a single integer t ( 1≤t≤1000 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤50 ) — the length of the array a .
The second line of each test case contains n space-separated integers a1,a2,…,an ( 1≤ai≤106 ) — representing the array a .
Do note that the sum of n over all test cases is not bounded.
输出格式
For each test case, output the minimum number of operations needed to make a good.
输入输出样例
输入#1
4 4 1 1 1 1 2 7 4 3 1 2 4 1 15
输出#1
0 2 1 4
说明/提示
In the first test case, array a is already good.
In the second test case, we can perform on index 2 twice. After the first operation, array a becomes [7,2] . After performing on index 2 again, a becomes [7,1] , which is good. It can be proved that it is not possible to make a good in less number of operations.
In the third test case, a becomes [0,2,4] if we perform the operation on index 1 once. As [0,2,4] is good, answer is 1 .
In the fourth test case, we need to perform the operation on index 1 four times. After all operations, a becomes [0] . It can be proved that it is not possible to make a good in less number of operations.