Problem description |
给定2n+1个数字,只有一个数字出现了奇数次,其余的数字都出现了偶数次,现在你需要找出出现奇数次的数字。 |
Input |
包含多组数据,每组数据第一行为一个数n(0<=n<=5000000)。接下来一行包括2n+1个数字(小于1000000000)。 |
Output |
对于每组数据,输出出现奇数次的数字. |
Sample Input |
1 1 1 1 2 1 2 1 3 3 3 1 1 2 2 3 3 4 |
Sample Output |
1 2 4 |
#include<stdio.h>
int main()
{
//freopen("a.txt","r",stdin);
int i,n,index,x;
while(scanf("%d",&n)==1)
{
index=0;
for(i=1;i<=2*n+1;i++)
{
scanf("%d",&x);
index^=x;
}
printf("%d\n",index);
}
return 0;
}