fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define e "\n"
  5. #define all(s) s.begin(), s.end()
  6. #define sz(s) (int)s.size()
  7. #define pi 3.14159
  8. #define lpi 3.141592653
  9. #define llpi 3.141592653589
  10. void FOLaa() {
  11. std::ios_base::sync_with_stdio(NULL);
  12. cin.tie(0);
  13. cout.tie(0);
  14. }
  15. const int N = 2e5 + 5;
  16.  
  17. int main()
  18. {
  19. FOLaa();
  20. int t;
  21. cin >> t;
  22. while (t--)
  23. {
  24. int n,x;
  25. cin >> n>>x;
  26. cout<<0<<" ";
  27. while(--n)
  28. {
  29. int a;
  30. cin>>a;
  31. cout<<((a|x)^a)<<" ";
  32. x|=a;
  33. }
  34. cout << e;
  35. }
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5476KB
stdin
5
4
1 3 7 15
4
1 2 4 8
5
1 2 3 4 5
4
11 13 15 1
1
0
stdout
0 0 0 0 
0 1 3 7 
0 1 0 3 2 
0 2 0 14 
0