2689."Or" Game

Time Limit: 1s Memory Limit: 256MB

You are given n numbers a1,a2,...,an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make 2689_1.png as large as possible, where 2689_2.png denotes the bitwise OR. Find the maximum possible value of 2689_1.png after performing at most k operations optimally.

Input Format(From the terminal/stdin)

Input The first line contains three integers n, k and x (1 \le n \le 200000, 1 \le k \le 10, 2 \le x \le 8).The second line contains n integers a1,a2,...,an (0 \le ai \le 109).

Output Format(To the terminal/stdout)

Output Output the maximum value of a bitwise OR of sequence elements after performing operations.

Sample Input 1

Copy
3 1 2
1 1 1
 · · \n
 · · \n

Sample Output 1

Copy
3
 \n

Sample Input 2

Copy
4 2 3
1 2 4 8
 · · \n
 · · · \n

Sample Output 2

Copy
79
  \n

Hints

For the first sample, any possible choice of doing one operation will result the same three numbers 1, 1, 2 so the result is 2689_3.png. For the second sample if we multiply 8 by 3 two times we'll get 72. In this case the numbers will become 1, 2, 4, 72 so the OR value will be 79 and is the largest possible result.

Submit

请先 登录

© 2025 FAQs