My issue
solution
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
bool has_zero = false;
int total_or = 0;
for (int i = 0; i < N; ++i) {
cin >> A[i];
total_or |= A[i];
if (A[i] == 0) has_zero = true;
}
if (total_or == 0) {
cout << "1\n";
continue;
}
int bits = __builtin_popcount(total_or);
int candidate = bits + (has_zero ? 1 : 0);
int ans = min(candidate, N);
cout << ans << "\n";
}
return 0;
}
Problem Link: Prefix OR Practice Coding Problem