记录编号 |
158520 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[CQOI2013]新Nim游戏 |
最终得分 |
100 |
用户昵称 |
真呆菌 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.003 s |
提交时间 |
2015-04-15 17:51:11 |
内存使用 |
0.29 MiB |
显示代码纯文本
- #include<cstdio>
- #include<algorithm>
- using namespace std;
- const int MaxBit = 31;
- const int N = 110;
-
- int n,a[N],lb[N];
- long long res;
-
- bool Check(int x){
- for(int i=MaxBit;~i;i--){
- if((x>>i)&1){
- if(!lb[i]){lb[i]=x;return 1;}
- else x^=lb[i];
- }
- }
- return x;
- }
-
- int main(){
- #define Read
- #ifdef Read
- freopen("newnim.in","r",stdin);
- freopen("newnim.out","w",stdout);
- #endif
- scanf("%d",&n);
- for(int i=1;i<=n;i++) scanf("%d",&a[i]),res+=a[i];
- sort(a+1,a+n+1);
- for(int i=n;i>=1;i--)
- if(Check(a[i])) res-=a[i];
- if(res==0) res=-1;
- printf("%lld\n",res);
- return 0;
- }