Wrong Answer
代码
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> bitCounts(32, 0); // To store the count of '1's for each bit position.
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
for (int j = 0; j < 32; ++j) {
if (x & (1 << j)) {
bitCounts[j]++;
}
}
}
long long result = 0;
for (int count : bitCounts) {
// Combination formula: C(n, 2) = n * (n - 1) / 2
if (count > 1) {
result += count * (count - 1) / 2;
}
}
cout << result << endl;
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1002 统计
- 语言
- C++
- 递交时间
- 2024-09-10 19:29:19
- 评测时间
- 2024-09-10 19:29:19
- 评测机
- 分数
- 0
- 总耗时
- 352ms
- 峰值内存
- 424.0 KiB