CF1277B.Make Them Odd

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn positive integers a1,a2,,ana_1, a_2, \dots, a_n . For the one move you can choose any even value cc and divide by two all elements that equal cc .

For example, if a=[6,8,12,6,3,12]a=[6,8,12,6,3,12] and you choose c=6c=6 , and aa is transformed into a=[3,8,12,3,3,12]a=[3,8,12,3,3,12] after the move.

You need to find the minimal number of moves for transforming aa to an array of only odd integers (each element shouldn't be divisible by 22 ).

输入格式

The first line of the input contains one integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases in the input. Then tt test cases follow.

The first line of a test case contains nn ( 1n21051 \le n \le 2\cdot10^5 ) — the number of integers in the sequence aa . The second line contains positive integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1091 \le a_i \le 10^9 ).

The sum of nn for all test cases in the input doesn't exceed 21052\cdot10^5 .

输出格式

For tt test cases print the answers in the order of test cases in the input. The answer for the test case is the minimal number of moves needed to make all numbers in the test case odd (i.e. not divisible by 22 ).

输入输出样例

  • 输入#1

    4
    6
    40 6 40 3 20 1
    1
    1024
    4
    2 4 8 16
    3
    3 1 7
    

    输出#1

    4
    10
    4
    0
    

说明/提示

In the first test case of the example, the optimal sequence of moves can be as follows:

  • before making moves a=[40,6,40,3,20,1]a=[40, 6, 40, 3, 20, 1] ;
  • choose c=6c=6 ;
  • now a=[40,3,40,3,20,1]a=[40, 3, 40, 3, 20, 1] ;
  • choose c=40c=40 ;
  • now a=[20,3,20,3,20,1]a=[20, 3, 20, 3, 20, 1] ;
  • choose c=20c=20 ;
  • now a=[10,3,10,3,10,1]a=[10, 3, 10, 3, 10, 1] ;
  • choose c=10c=10 ;
  • now a=[5,3,5,3,5,1]a=[5, 3, 5, 3, 5, 1] — all numbers are odd.

Thus, all numbers became odd after 44 moves. In 33 or fewer moves, you cannot make them all odd.

首页