# SGU 275 to XOR or not to XOR "maximum XOR and Gaussian elimination"

Source: Internet
Author: User

To give you the number of n (n<=100) to find out a number of numbers to make them different or and maximum

Idea: Gaussian-if the elimination of the elimination of the element after the cut into a number of independent line vectors, they will be different or up good

#include <cstdio>

#include <string.h>

#include <iostream>

#include <algorithm>

#define MAXN 3000

#define LL __int64

using namespace Std;

LL BIN[MAXN],A[MAXN];

int main ()

{

int n;

scanf ("%d", &n);

for (int i=1;i<=n;i++) scanf ("%i64d", &a[i]);

for (int i=1;i<=61;i++) bin[i]= (1ll<< (i-1));

int now=0;

for (int i=61;i>=1;i--)

{

int idx=now+1;

while ((A[idx]&bin[i]) ==0 && idx<=n) idx++;

if (idx==n+1) continue;

Swap (a[idx],a[now+1]);

now++;

for (int j=1;j<=n;j++) if ((A[j]&bin[i])!=0 && now!=j) A[j]^=a[now];

}

LL ans=0;

for (int i=1;i<=n;i++) ans^=a[i];

printf ("%i64d\n", ans);

return 0;

}

SGU 275 to XOR or not to XOR "maximum XOR and Gaussian elimination"

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.