#P12555. [UOI 2024] AND Array
[UOI 2024] AND Array
题目描述
An integer and an array of non-negative integers are given. All elements of the array are less than .
Let's define (, ) as the result of the following pseudocode:
res = 0
x = power(2, p)
for i = s to n:
if ((x AND a[i]) == 0):
x = (x OR a[i])
res = res + i
return res
Here, power(2, p)
denotes , AND
denotes the bitwise operation, and OR
denotes the bitwise operation.
The bitwise of non-negative integers and is equal to a non-negative integer, in which the binary representation has a one at a certain position only if both binary representations of and have ones at that position. For example, AND AND .
The bitwise of non-negative integers and is equal to a non-negative integer, in which the binary representation has a zero at a certain position only if both binary representations of and have zeros at that position. For example, OR OR .
For each from to , find
输入格式
The first line contains two integers and (, ) --- the length of array and the limit on the elements of the array, respectively.
The second line contains integers () --- the elements of array .
输出格式
Output integers --- the required values.
5 3
0 2 1 3 4
23 20 16 14 10
3 2
1 3 2
4 3 3
提示
In the first example, , , , and the first of the required values is equal to .
Scoring
- ( points): ;
- ( points): , where is an integer;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): without additional constraints.