线性基模板 发表于 2021-11-28 分类于 OI 本文字数: 799 阅读时长 ≈ 1 分钟 标签:     模板     数学     线性基 用于求解线性代数问题。 以异或为例。 更一般的,在实数上的应用见其他题目。 查看代码 1234567891011121314151617181920212223242526272829303132333435363738#include <cstdio>#include <algorithm>using namespace std;const int N = 60;typedef long long LL;int n;LL c[N];void insert(LL x){ for (int i = 50; ~i; i--) if (x >> i & 1) { if (!c[i]) { c[i] = x; return; } x ^= c[i]; }}LL query(){ LL res = 0; for (int i = 50; ~i; i--) res = max(res, res ^ c[i]); return res;}int main(){ scanf("%d", &n); for (LL a; n; n--) { scanf("%lld", &a); insert(a); } printf("%lld", query()); return 0;} 相关文章 高斯消元模板 求逆元的方法 2-SAT 模板 三维凸包模板 BSGS 模板 本文作者: RuSun 本文链接: https://rusunoi.github.io/post/Linear-Basis-Template/ 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!