拿下双修,求点赞,我想要解题仙人
2025-11-30 13:05:47
发布于:内蒙古
23阅读
0回复
0点赞
#include <cstdio>
#include <cctype>
const int MAX_N = 1000000;
int arr[MAX_N];
inline int read() {
int x = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
x = x * 10 + (c - '0');
c = getchar();
}
return x;
}
int main() {
int n = read();
int xor_sum = 0;
for (int i = 0; i < n; i++) {
arr[i] = read();
xor_sum ^= arr[i];
}
if (xor_sum == 0) {
printf("0");
return 0;
}
int count = 0;
int high_bit = 1 << 30;
while ((xor_sum & high_bit) == 0) {
high_bit >>= 1;
}
for (int i = 0; i < n; i++) {
if (arr[i] & high_bit) {
count++;
}
}
printf("%d", count);
return 0;
}







有帮助,赞一个