luogu P5514 [MtOI2019] stay night retribution

Topic background

In this world there is a village a forest a bamboo pavilion, there is also a master-servant a foe.

Some people have wanted to take their figure, it was cute bunny confused mind.

Those who lost in the, ah, will eventually disappear in the immortal stay night in ......

Title Description

Penglai Shan-hui night (Kaguya) the hands of a bunch of numbers.

Hands-hui night there are n non-negative integers, due Hui Gal Game play night went, she hopes to help you wisdom.

You need these numbers are divided into groups, each satisfy the number nn is the number of all happens to be assigned to a group, and each group comprises at least one number.
Right value defines a set of numbers all the numbers within the group, and XOR. A packet requesting the right program, so that the number of all the groups separated and minimum values, and output the weighted sum of the minimum.

Input Format

The first line input comprises a positive integer n, the number given to the non-negative integer.

The next line contains a non-negative integer n

Output Format

A line output integer answer.

Metaphysical subject, all grouped output directly answer

a^b<=a+b

#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1e6;
int main(){
    int n,ans;
    cin>>n>>ans;
    for(int i=2,x;i<=n;i++){
        scanf("%d",&x);
        ans^=x;
    }
    cout<<ans<<endl;
}

Guess you like

Origin www.cnblogs.com/naruto-mzx/p/11653019.html