http://www.lydsy.com/JudgeOnline/problem.php?id=4269

裸线性基,一个数取多次就是没取。。。

又有了些新的理解:a数组的前now个元素是基底,也就是可以变成1的位,最大就是所有1都选,次大就是最后一个1不选

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
int n, now;
ll a[N], bin[];
void gauss()
{
now = ;
for(int i = ; i >= ; --i)
{
int x = now;
while(x <= n && !(a[x] & bin[i])) ++x;
if(x == n + ) continue;
swap(a[now], a[x]);
for(int j = ; j <= n; ++j) if(j != now && a[j] & bin[i])
a[j] ^= a[now];
++now; //下一个数 ,下一个自由位
}
--now;
}
int main()
{
bin[] = ; for(int i = ; i <= ; ++i) bin[i] = bin[i - ] * ;
scanf("%d", &n);
for(int i = ; i <= n; ++i) scanf("%d", &a[i]);
gauss();
ll ans = ;
for(int i = ; i <= now; ++i) ans ^= a[i];
printf("%lld %lld\n", ans, ans ^ a[now]); //a[now]是最低的位
return ;
}

最新文章

  1. 【Beta】Daily Scrum Meeting第四次
  2. C++中数据对齐
  3. Winform以任意角度旋转PictureBox中的图片的方法
  4. DotNetBar的初步使用
  5. MKCOL not allowed
  6. 集合删数 (vijos 1545) 题解
  7. SQL面试题——查询课程
  8. 华硕A450c详细清灰拆机教程
  9. spring事务源码解析
  10. C#设置WebBrowser默认浏览器
  11. 基于Spring Cloud、JWT 的微服务权限系统设计
  12. 1062 Text Reverse
  13. 搭建Python自动化测试环境+元素定位
  14. linklist和arraylist区别
  15. ES6躬行记(7)——代码模块化
  16. Lodop打印html数字间隔不一致
  17. C# dataGridView 如何选中整行?
  18. ios开发常用封装的实用方法
  19. 第四课(1)——MySQL体系结构
  20. iOS App之间常用的五种通信方式及适用场景总结

热门文章

  1. ubuntu 安装 navicat
  2. Poj 2187 凸包模板求解
  3. 第二周习题O题
  4. [bzoj1112][POI2008]砖块Klo_非旋转Treap
  5. codevs——1385 挤牛奶
  6. codevs——1039 数的划分
  7. 移动端 js 实现图片上传 预览
  8. 网页页面NULL值对浏览器兼容性的影响
  9. C# .NET 如何修改代码字体
  10. EC2的维护更新-总结篇及有效经验分享