Description
给定些数字,这些数中只有一个数出现了奇数次,找出这个数。
Input
每组数据第一行n表示数字个数,1 <= n <= 2 ^ 18 且 n % 2 == 1。
接下来n行每行一个32位有符号整数。
Output
出现奇数次那个数,每组数据对应一行。
Sample Input
5 1 1 2 2 3 7 1 2 1 2 2 3 3
Sample Output
3 2
Hint
用位运算
#include<stdio.h>
int main()
{
int T;
while (~scanf("%d", &T))
{
int x;
int cnt = 0;
while (T--)
{
scanf("%d", &x);
cnt ^= x;
}
printf("%d\n", cnt);
}
return 0;
}
/**********************************************************************
Problem: 1217
User: leo6033
Language: C++
Result: AC
Time:416 ms
Memory:1120 kb
**********************************************************************/