每位只要不都为0则为1
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;
inline char nc()
{
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(ll &x)
{
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=500005;
ll n,m,ans;
ll a[N];
int main()
{
int cnt=0,pnt;
freopen("t.in","r",stdin);
freopen("t.out","w",stdout);
read(n); read(m);
for (int i=1;i<=n;i++)
read(a[i]),a[i]^=a[i-1];
for (int k=63;~k;k--)
{
cnt=0;
for (int i=1;i<=n;i++)
if (!(a[i]&(1LL<<k)))
cnt++;
if (cnt>=m && !(a[n]&(1LL<<k)))
{
pnt=0;
for (int i=1;i<=n;i++)
if (!(a[i]&(1LL<<k)))
a[++pnt]=a[i];
n=pnt;
}
else
ans+=(1LL<<k);
}
printf("%lld\n",ans);
return 0;
}