308938: CF1601A. Array Elimination
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Array Elimination
题意翻译
### 题目描述 有一个长度为 $n$ 的序列 $a_1,a_2,\dots,a_n$,每次操作选择 $k$ 个数,将这 $k$ 个数减去他们的与(二进制运算中的与)的和。求哪些 $k$ 可以在有限次操作内使所有数变成 $0$。 ### 输入格式 第一行一个正整数 $t$ 表示数据组数。 对于每一组数据,第一行输入一个正整数 $n$ 表示序列长度,第二行输入 $n$ 个非负整数表示序列 $a$ 。 ### 输出格式 对于每一组数据,输出一行,从小到大输出每一个可能的 $k$ ,两个数之间用空格隔开。 ### 数据范围 $1\le t\le10^4,1\le\sum n\le2\times10^5,0\le a_i<2^{30}$。题目描述
You are given array $ a_1, a_2, \ldots, a_n $ , consisting of non-negative integers. Let's define operation of "elimination" with integer parameter $ k $ ( $ 1 \leq k \leq n $ ) as follows: - Choose $ k $ distinct array indices $ 1 \leq i_1 < i_2 < \ldots < i_k \le n $ . - Calculate $ x = a_{i_1} ~ \& ~ a_{i_2} ~ \& ~ \ldots ~ \& ~ a_{i_k} $ , where $ \& $ denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND) (notes section contains formal definition). - Subtract $ x $ from each of $ a_{i_1}, a_{i_2}, \ldots, a_{i_k} $ ; all other elements remain untouched. Find all possible values of $ k $ , such that it's possible to make all elements of array $ a $ equal to $ 0 $ using a finite number of elimination operations with parameter $ k $ . It can be proven that exists at least one possible $ k $ for any array $ a $ . Note that you firstly choose $ k $ and only after that perform elimination operations with value $ k $ you've chosen initially.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \leq t \leq 10^4 $ ). Description of the test cases follows. The first line of each test case contains one integer $ n $ ( $ 1 \leq n \leq 200\,000 $ ) — the length of array $ a $ . The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 0 \leq a_i < 2^{30} $ ) — array $ a $ itself. It's guaranteed that the sum of $ n $ over all test cases doesn't exceed $ 200\,000 $ .
输出格式
For each test case, print all values $ k $ , such that it's possible to make all elements of $ a $ equal to $ 0 $ in a finite number of elimination operations with the given parameter $ k $ . Print them in increasing order.
输入输出样例
输入样例 #1
5
4
4 4 4 4
4
13 7 25 19
6
3 5 3 1 7 1
1
1
5
0 0 0 0 0
输出样例 #1
1 2 4
1 2
1
1
1 2 3 4 5