题库练习 Add, Divide and Floor
← 上一题 下一题 →

A16298 | Add, Divide and Floor

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

题目描述

You are given an integer array $a_1, a_2, \dots, a_n$ ( $0 \le a_i \le 10^9$ ). In one operation, you can choose an integer $x$ ( $0 \le x \le 10^{18}$ ) and replace $a_i$ with $\lfloor \frac{a_i + x}{2} \rfloor$ ( $\lfloor y \rfloor$ denotes rounding $y$ down to the nearest integer) for all $i$ from $1$ to $n$ . Pay attention to the fact that all elements of the array are affected on each operation.

Print the smallest number of operations required to make all elements of the array equal.

If the number of operations is less than or equal to $n$ , then print the chosen $x$ for each operation. If there are multiple answers, print any of them.

输入格式

The first line contains a single integer $t$ ( $1 \le t \le 10^4$ ) — the number of testcases.

The first line of each testcase contains a single integer $n$ ( $1 \le n \le 2 \cdot 10^5$ ).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $0 \le a_i \le 10^9$ ).

The sum of $n$ over all testcases doesn't exceed $2 \cdot 10^5$ .

输出格式

For each testcase, print the smallest number of operations required to make all elements of the array equal.

If the number of operations is less than or equal to $n$ , then print the chosen $x$ for each operation in the next line. If there are multiple answers, print any of them.

输入输出样例

输入 #1
4
1
10
2
4 6
6
2 1 2 1 2 1
2
0 32
输出 #1
0
2
2 5
1
1
6
C++ 编辑器
输入
输出