参考博客
题目大意:在集合中找出 k (k≤2)个出现了奇数次的正整数 a。
并按从小到大的顺序输出出来

#include<bits/stdc++.h>
using namespace std;
int a[33],c[33];
int main()
{
    ios::sync_with_stdio(false);
    int n,x,k;
    cin>>n>>k;
    int ans  =0;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        ans^=x;
        for(int j=31;j>=0;j--)
        {
            if(x&(1<<j)){
                a[j]^=x;
                c[j]+=1;
            }
        }
    }
        int A,B;
        if(k==1)
        {
            cout<<ans<<endl;
        }
        else
        {
            for(int j=31;j>=0;j--)
            {
                if(c[j]%2)
                {
                    A = a[j];
                    break;
                }
            }
            B = ans^A;
            if(A>B)swap(A,B);
            cout<<A<<" "<<B<<endl;
        }


    return 0;
}

加强版
k<=500