fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int T;
  6. cin>>T;
  7. while(T--){
  8. int N;cin>>N;
  9. int arr[N+1];
  10. for(int i =0 ; i < N; i++)cin>>arr[i];
  11. for(int i = 0 ; i < N; i++){
  12. int a = 0;
  13. for(int j = 0; j < N; j++){
  14. if(i == j) continue;
  15. a ^= arr[j];
  16. }
  17. if(arr[i] == a) {cout<<arr[i]<<'\n'; break;}
  18. }
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5492KB
stdin
4
4
4 3 2 5
5
6 1 10 7 10
6
6 6 6 6 6 6
3
100 100 0
stdout
4
6
6
100