308989: CF1609A. Divide and Multiply
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Divide and Multiply
题意翻译
给定长度为 $n$ 的序列 $a$,可以进行任意次操作,最大化 $\sum\limits_{i=1}^n a_i$。 一次操作是选两个下标 $i,j$,其中 $a_i$ 是偶数,把 $a_i/2,a_j\times 2$。 多组数据,$1\le t\le 10^4,1\le n,a_i\le 15$。题目描述
![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1609A/ed5b77bcb83c3732516ccac033270f15c3ac243c.png)William has array of $ n $ numbers $ a_1, a_2, \dots, a_n $ . He can perform the following sequence of operations any number of times: 1. Pick any two items from array $ a_i $ and $ a_j $ , where $ a_i $ must be a multiple of $ 2 $ 2. $ a_i = \frac{a_i}{2} $ 3. $ a_j = a_j \cdot 2 $ Help William find the maximal sum of array elements, which he can get by performing the sequence of operations described above.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). Description of the test cases follows. The first line of each test case contains an integer $ n $ $ (1 \le n \le 15) $ , the number of elements in William's array. The second line contains $ n $ integers $ a_1, a_2, \dots, a_n $ $ (1 \le a_i < 16) $ , the contents of William's array.
输出格式
For each test case output the maximal sum of array elements after performing an optimal sequence of operations.
输入输出样例
输入样例 #1
5
3
6 4 2
5
1 2 3 4 5
1
10
3
2 3 4
15
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
输出样例 #1
50
46
10
26
35184372088846