#P13565. 「CZOI-R5」按位或

    ID: 14411 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心洛谷原创O2优化位运算洛谷比赛

「CZOI-R5」按位或

Problem Description

You have a sequence aa of length nn. Now you can perform at most mm operations. In each operation, you may choose an index 1in1 \le i \le n and change aia_i to 2×ai2 \times a_i. Find the minimum possible value of the bitwise OR of the final sequence aa, that is, the minimum of ori=1nai\operatorname{or}_{i=1}^n a_i.

or\operatorname{or} refers to the bitwise OR operation.

Input Format

The first line contains an integer nn, denoting the length of the sequence.

The second line contains nn integers, denoting the sequence aa.

The third line contains an integer mm, denoting the maximum number of operations.

Output Format

Output one integer on the first line, denoting the answer.

3
5 1 4
1
5
2
1 2
1
2

Hint

[Sample Explanation #1]

You may choose to perform no operations.

[Sample Explanation #2]

Choose i=1i = 1, then a1a_1 becomes 2×1=22 \times 1 = 2, and the bitwise OR of the sequence aa is 22.

[Constraints]

This problem uses bundled testdata.

  • Subtask #1 (15 pts15\text{ pts}): n8n \le 8, m8m \le 8, ai103a_i \le 10^3.
  • Subtask #2 (25 pts25\text{ pts}): n103n \le 10^3, m104m \le 10^4, ai106a_i \le 10^6.
  • Subtask #3 (25 pts25\text{ pts}): n103n \le 10^3, ai2×103a_i \le 2 \times 10^3.
  • Subtask #4 (35 pts35\text{ pts}): No special constraints.

For 100%100\% of the data, 1n1061 \le n \le 10^6, 1m1061 \le m \le 10^6, 0ai1090 \le a_i \le 10^9.

Translated by ChatGPT 5