题目大意:
给出N个正整数,其中只有一个数出现了奇数次,其余的数都出现偶数次。
求那个出现了奇数次的数。1<=N<=500000,N肯定是奇数。所有出现数都不超过10000。
解题思路:
首先,看到这样的题目我是惊呆了~在纪中,就算是做D组也是第一次这么简单~
一个桶最快,空间最小
这么水的题,代码还需要解析?当然不需要 我就是懒
#include <cstdio>
using namespace std;
int n,x,a[10001];
int main()
{
// freopen("count.in","r",stdin);
// freopen("count.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
scanf("%d",&x),a[x]++;
for (int i=0;i<=10000;i++)
if (a[i]%2==1) printf("%d ",i);
return 0;
}