Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("d.in");
- int n;
- int t;
- int a[200005];
- map <int, int> mp;
- int main()
- {
- fin >> t;
- while (t--)
- {
- fin >> n;
- for (int i = 1; i <= n; i++)
- {
- fin >> a[i];
- if (a[i] % 2 == 0)
- mp[a[i]]++;
- }
- map <int, int>::iterator it;
- int ans = 0;
- mp[1]++;
- for (it = mp.end(); it != mp.begin(); it--)
- {
- int x = it->first;
- cout << x << " ";
- if (x % 2 != 0)
- continue;
- mp[x/2]++;
- ans++;
- }
- cout << ans << "\n";
- mp.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement