P5514 [MtOI2019] 永夜的报应

原题链接

题解

由于 \(a\oplus b \leq a+b\) ,所以全部异或起来

code

#include<bits/stdc++.h>
#define ll long long
using namespace std;

void solve()
{
    int n;
    cin>>n;

    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        ans^=x;
    }
    cout<<ans<<'\n';
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


posted @ 2024-07-21 17:22  纯粹的  阅读(13)  评论(0)    收藏  举报