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