Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("d.in");
  6.  
  7. int n;
  8. int t;
  9. int a[200005];
  10.  
  11. map <int, int> mp;
  12.  
  13. int main()
  14. {
  15.     fin >> t;
  16.     while (t--)
  17.     {
  18.         fin >> n;
  19.         for (int i = 1; i <= n; i++)
  20.         {
  21.             fin >> a[i];
  22.             if (a[i] % 2 == 0)
  23.                 mp[a[i]]++;
  24.         }
  25.         map <int, int>::iterator it;
  26.         int ans = 0;
  27.         mp[1]++;
  28.         for (it = mp.end(); it != mp.begin(); it--)
  29.         {
  30.             int x = it->first;
  31.             cout << x << " ";
  32.             if (x % 2 != 0)
  33.                 continue;
  34.             mp[x/2]++;
  35.             ans++;
  36.         }
  37.         cout << ans << "\n";
  38.         mp.clear();
  39.     }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement