fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(NULL);
  7.  
  8. int n;
  9. cin >> n;
  10. vector<int> arr(n);
  11. for(int i = 0; i < n; i++){
  12. cin >> arr[i];
  13. }
  14.  
  15. vector<int> count_one(32, 0);
  16. for(int j = 0; j < n; j++){
  17. for(int bit = 0; bit < 32; bit++){
  18. if((arr[j] >> bit) & 1){
  19. count_one[bit]++;
  20. }
  21. }
  22. }
  23.  
  24. unsigned int y = 0;
  25. for(int i = 0; i < 32; i++){
  26. int c_one = count_one[i];
  27. int c_zero = n - c_one;
  28. if(c_zero > c_one && count_one[i]!=0){
  29. y |= (1U << i);
  30. }
  31. }
  32.  
  33. cout << y << endl;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
2 3 5 8 10
stdout
13