Advertisement
deushiro

Untitled

Dec 14th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <queue>
  6. #include <map>
  7. #include <set>
  8. #include <bitset>
  9. #include <algorithm>
  10.        
  11. using namespace std;
  12.  
  13. typedef long long ll;
  14.  
  15. int main() {
  16.     int t;
  17.     cin >> t;
  18.     while(t--){
  19.         int n;
  20.         int ans = 0;
  21.         cin >> n;
  22.         priority_queue<int> a;
  23.         map<int, bool> m;
  24.         for(int i = 0; i < n; ++i){
  25.             int x;
  26.             cin >> x;
  27.             if(!m[x]){
  28.                 a.push(x);
  29.             }
  30.             m[x] = true;
  31.         }
  32.         while(a.size() > 0){
  33.             int x = a.top();
  34.             a.pop();
  35.             if(x % 2 == 1){
  36.                 continue;
  37.             }
  38.             else{
  39.                 if(!m[x / 2])
  40.                     a.push(x / 2);
  41.                 ++ans;
  42.             }
  43.         }
  44.         cout << ans << "\n";
  45.        
  46.     }
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement