计蒜客♂计蒜客♂计蒜客♂计蒜客

[模板]线性基

2019-02-23 15:42:23


this page is good

BobH 博客引流

题解 CF1225D 【Power Products】

BobH的gal引擎

长沙十天集训总结

长郡第3次集训总结

2019.3 长郡省选集训算法总结

使用PHP搭建一个自己的英文句式搜索引擎

Vue学习笔记

如何使Typecho博客快速被百度收录

数列的递推形式

斜率优化学习笔记

高等数学学习笔记

使用docker安装gitlab中文版记录

线性基模板

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 50;
const int maxbit = 64;
int n;
ll a[maxn],p[maxbit];
int main(){
    scanf("%d",&n);
    memset(a,0,sizeof a);
    memset(p,0,sizeof p);
    for(int i=1;i<=n;i++){
        scanf("%lld",a+i);
        //构造线性鸡
        for(int j=62;j>=0;j--){
            if(!(a[i]>>j)) continue;
            if(!p[j]){
                p[j] = a[i];
                break;
            }
            a[i] ^= p[j];
        } 
    }
    ll ans = 0;
    for(int i=62;i>=0;i--){
        ans = max(ans,ans^p[i]);
    }
    printf("%lld",ans);
    return 0;
}