sgu275:To xor or not to xor(最大异或和)
来源:互联网 发布:qq直播是什么软件 编辑:程序博客网 时间:2024/06/07 17:17
题目大意:
分析:
AC code:
#include <cstdio>#include <cmath>#include <cstdlib>#include <cstring>#include <cctype>#include <algorithm>#include <string>#include <sstream>#include <iostream>#include <map>#include <set>#include <list>#include <stack>#include <queue>#include <vector>#define get(s, x) (((s)>>(x))&1)#define pb push_back#define mp make_pairtypedef long long LL;typedef double DB;typedef long double LD;using namespace std;const int MAXN = 109;int n;LL a[MAXN];int main(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif scanf("%d", &n); for(int i = 1; i <= n; ++i) cin >> a[i]; int st = 1; for(int i = 63; i >= 0; --i) { bool flag = false; for(int j = st; j <= n; ++j) if(get(a[j], i)) { swap(a[j], a[st]); flag = true;break; } if(flag) { for(int j = 1; j <= n; ++j) if(j != st && get(a[j], i)) a[j] ^= a[st]; st++; } } LL ans = 0; for(int i = 1; i <= n; ++i) ans ^= a[i]; cout << ans << endl; #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif return 0;}
0 0
- sgu275:To xor or not to xor(最大异或和)
- sgu275--To xor or not to xor(高斯消元问题5,子序列异或的最大和)
- sgu275 To xor or not to xor ----高斯消元复习
- [SGU275]To xor or not to xor 枚举+高斯消元
- 高斯消元 SGU275 To xor or not to xor
- 【高斯消元】[SGU275]To xor or not to xor
- 【高斯消元】[SGU275]To xor or not to xor
- SGU275. To xor or not to xor(高斯消元求N个数中任取M个数求得异或最大值)
- To xor or not to xor 高斯消元求异或
- 275. To xor or not to xor(高斯消元求最大亦或值)
- To xor or not to xor SGU
- 异或思维题--to xor or not to xor nkoj3734
- SGU_275 To xor or not to xor gauss
- SGU 275 To xor or not to xor
- 【SGU 275】 To xor or not to xor
- SGU 275. To xor or not to xor(高斯消元)
- SGU 275 To xor or not to xor (高斯消元)
- SGU 275 To xor or not to xor (高斯消元)
- POJ--1661(DP)
- 监督学习&回归问题(Regression)
- 自己实现基于key-value的NoSQL数据库(一)——起步,初版
- gradle入门指南
- jquery 使用方法
- sgu275:To xor or not to xor(最大异或和)
- JXL报BiffException解决方案
- poj 1936 All in All
- 单链表C++类模板实现
- Mysql Oracle Java 数据类型对照
- Effective C++条款26解读: 尽可能延后变量定义式的出现时间
- 在VS2010下MFC采用ADO方式连接ACCESS数据库(详细过程)
- 学习笔记(objective-c)-协议(protocol)
- 归并排序