Time Exceeded
/in/foo.cc: In function 'int main()':
/in/foo.cc:21:44: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
while ((nums[i] >> highestBit) & 1 == 0) {
~~^~~~
代码
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i) {
cin >> nums[i];
}
long long result = 0;
for (int i = 0; i < n; ++i) {
int highestBit = 0;
while ((nums[i] >> highestBit) & 1 == 0) {
++highestBit;
}
for (int j = i + 1; j < n; ++j) {
if (((nums[j] >> highestBit) & 1) && (nums[i] & nums[j]) > (nums[i] ^ nums[j])) {
++result;
}
}
}
cout << result << endl;
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1002 统计
- 语言
- C++
- 递交时间
- 2024-09-10 19:30:29
- 评测时间
- 2024-09-10 19:30:29
- 评测机
- 分数
- 0
- 总耗时
- ≥8020ms
- 峰值内存
- ≥796.0 KiB