正在完成线性基板子题
始终WA#2 #3 #4 #5
百思不得其解
遂撅洛谷讨论区,得前人警示:位运算记得打括号
补上括号,遂AC
以上,警钟长鸣
附WA代码
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
ll d[100];
int n;
void Insert(ll x)
{
for(int i=62;i>=1;i--)
{
if(!(x>>(i-1))) continue;
if(!d[i])
{
d[i]=x;
return ;
}
else
{
x^=d[i];
}
}
}
ll FindMax()
{
ll ans=d[62];
for(int i=62;i>=1;i--)
{
if(ans^d[i]>ans) //**事故多发地段**
{
ans^=d[i];
}
}
return ans;
}
int main()
{
// freopen("working.in","r",stdin);
// freopen("working.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
ll x;
cin>>x;
Insert(x);
}
cout<<FindMax();
return 0;
}
标签:return,WA,int,ll,警钟,62,ans
From: https://www.cnblogs.com/yeyou26/p/17990611