Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <vector>
- using namespace std;
- bool nin(int x, set <int> s) {
- return s.find(x) == s.end();
- }
- int main() {
- int t, j;
- cin >> t;
- for (j = 0; j < t; j++){
- int n, x, k = 0, s = 0;
- vector <int> v;
- set <int> a;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> x;
- a.insert(x);
- }
- for (auto f : a) {
- if (f % 2 == 0) {
- s++;
- v.push_back(f);
- }
- }
- for (int i = s - 1; i >= 0; i--) {
- x = v[i];
- x /= 2;
- k++;
- while (nin(x, a) && x % 2 == 0) {
- x /= 2;
- k++;
- }
- a.erase(v[i]);
- }
- cout << k << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement