-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Divide_and_Conquer.cpp
56 lines (45 loc) · 1.16 KB
/
A_Divide_and_Conquer.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
// Everything in the Universe is Balanced
// Every Disappointment you face in life will be balanced with something good for you
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TestCases int TOTALTC ; cin >> TOTALTC ; for(__case__ = 1 ; __case__ <= TOTALTC ; __case__++)
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin() , (x).end()
#define nl "\n"
int __case__ = 1 ;
void solve()
{
int n ; cin >> n;
vector<int> v(n) ;
for(auto &x : v) cin >> x ;
vector<int> need(n) ;
for(int i = 0 ; i < n ; i++)
{
int x = v[i] ;
int parity = (x & 1) ;
int count = 0 ;
while(x)
{
x /= 2 ;
count++ ;
int currParity = (x & 1 ) ;
if(currParity != parity)
{
need[i] = count ;
break;
}
}
}
int sum = accumulate(all(v),0LL) ;
if(sum % 2 == 0 )
{
cout << 0 << nl ;
return ;
}
else
{
cout << *min_element(all(need)) << nl ;
}
}
signed main() { FAST TestCases solve(); }