hdu 2095 find your present (2)
^(异或)运算, 0 ^ a = a, a ^ b ^ b = a, a ^ (偶数个)b = a, 那么 0 ^ a ^ a = 0咯.
#include <stdio.h>
int main() {
int n;
int k, a;
int i;
while (scanf("%d", &n) != EOF && n) {
k = 0;
for (i = 0; i < n; i++) {
scanf("%d", &a);
k ^= a;
}
printf("%d\n", k);
}
return 0;
}