Advertisement
Josif_tepe

Untitled

Jul 31st, 2022
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int num;
  9.     cin >> num;
  10.     int x = 0;
  11.     for(int i = 0; i < num; i++) {
  12.         cin >> x;
  13.     }
  14.     cin >> num;
  15.     x = 0;
  16.     for(int i = 0; i < num; i++) {
  17.         int id;
  18.         cin >> id;
  19.        
  20.         x |= (1 << id);
  21.     }
  22.    
  23.     for(int i = 31; i >= 0; i--) {
  24.         if(x & (1 << i)) {
  25.             cout << i << " ";
  26.         }
  27.     }
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement