Linear yl (template)

Here the connection o ( '^ `) o

Linear Properties group:

1. any of a number of pro sequence which can be linear number by a number of groups of exclusive OR obtained inside.
2. Linear any group or inside some number of them can not give exclusive 0 0
number 3. Number of unique linear groups inside, and in the holding properties of a premise, the counted number is the least

//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#include<vector>

#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define sl(x) scanf("%lld",&(x))
#define rep(i,a,b) for(int i=a;i<=b;i++)

using namespace std;

int p[105];

void Insert(int now)
{
    per(i,62,0)
    {
        if((now&((ll)1<<i)))
        {
            if(!p[i])
            {
                p[i]=now;
                break;
            }
            now^=p[i];
        }
    }
}

#undef int
int main()
{
#define int long long
    int n;
    sl(n);
    rep(i,1,n)
    {
        int now;
        sl(now);
        Insert(now);
    }
    int ans=0;
    per(i,62,0)
        if((ans^p[i])>ans) ans^=p[i];
    cout<<ans<<"\n";

    return 0;
}

 

Guess you like

Origin www.cnblogs.com/minun/p/11329469.html