0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 05:28:50 +00:00
OI-codes/S2OJ/1036/1036.cpp

25 lines
506 B
C++

#include <bits/stdc++.h>
using namespace std;
int n;
long long x, a[1000005], pre[1000005], suf[1000005], ans;
int main() {
cin >> n >> x;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
pre[i] = pre[i - 1] | a[i];
}
for (int i = n; i >= 1; i--) {
suf[i] = suf[i + 1] | a[i];
}
for (int i = 1; i <= n; i++) {
ans = max(ans, pre[i - 1] | (a[i] * x) | suf[i + 1]);
}
cout << ans << endl;
return 0;
}