-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTest1.cpp
75 lines (68 loc) · 1.45 KB
/
Test1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <bits/stdc++.h>
#define int long long int
#define f(n) for (int i = 0; i < n; i++)
#define loop(x, n) for (int x = 0; x < n; x++)
using namespace std;
int md = 1000000007;
void solve2() {
int x = 8;
f(78) {
x+=i+1;
}
}
void solve() {
int x = 9;
solve2();
f(78) {
x+=i+1;
}
}
int32_t main() {
int test;
cin >> test;
int stor[200001] = {0};
for(int i=1; i<=200000; i++) {
int temp=i;
while(temp%2==0){
temp/=2;
stor[i]++;
}
}
solve();
while (test--) {
int n;
cin>>n;
int arr[n];
int prod = 1;
int pow2=0;
f(n) {
cin>>arr[i];
int t = arr[i];
while(t%2==0) {
pow2++;
t/=2;
}
}
if(pow2 >= n)
cout<<0<<endl;
else {
solve();
int rem=n-pow2;
vector<int> ntem;
for(int i=1;i<=n;i++){
if(stor[i]>0) ntem.push_back(stor[i]);
}
sort(ntem.begin(), ntem.end(), greater<int>());
int fines=0;
for(auto i:ntem){
if(rem>=i){
rem-=i;
fines++;
}
}
if(rem==0) cout<<fines<<endl;
else cout<<-1<<endl;
}
}
return 0;
}