logo AlgoBeat OnlineJudge
登录 注册

#212613. [UOI 2024] AND Array

内存限制:512 MiB 时间限制:7000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

样例

样例输入 1

5 3
0 2 1 3 4

样例输出 1

23 20 16 14 10

样例输入 2

3 2
1 3 2

样例输出 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.