Problem 1723 我就不信你能找得到. 思路 对每组数据排序遍历排序后的数组,当后一个和当前不一样时: 当前累积是奇数吗?是–存入结果数组 vc++AC, GUN++WA 代码 #include<stdio.h> #include<algorithm> using namespace std; typedef long long LL; LL ans[2], v[1000000]; int len; int main(){ int t, n, count; scanf("%d", &t); while(t--){ len = 0; scanf("%d", &n); for(int i=0; i<n; i++) scanf("%lld", &v[i]); sort(v, v+n); count = 1; for(int i=0; i<n; i++){ #为什么和后一位比要到n:最后一位v[n]如果不比较一下不会进答案数组 if(v[i+1]==v[i]) count++; else{ if(count%2==1) ans[len++] = v[i]; count = 1; } } for(int i=0; i<len; i++){ printf("%lld", ans[i]); if(i!=len-1) printf(" "); else printf("\n"); } } return 0; }