QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#752431 | #858. GCD vs. XOR | kangkunma | WA | 256ms | 91308kb | C++20 | 1.3kb | 2024-11-16 02:55:39 | 2024-11-16 02:55:39 |
Judging History
answer
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
const int MAX = 1000001;
vector<vector<int>> D(MAX);
void initialize() {
for (int i = 0; i < 1000; ++i) {
for (int j = i + 1; j < MAX / (i + 1); ++j) {
if (((i + 2) * j == j | (i + 1) * j)) {
D[(i + 1) * j].push_back(i + 1);
}
}
}
cout << "done" << endl;
}
long long s(const vector<int>& l) {
vector<int> C(MAX, 0);
long long A = 0;
for (int i : l) {
C[i]++;
}
set<int> unique_l(l.begin(), l.end());
for (int i : unique_l) {
for (int j : D[i]) {
if (i + j > MAX) break;
if ((i + j) == (j | i)) {
A += static_cast<long long>(C[i]) * C[j + i];
}
if (i / j + i <= MAX) {
if ((i + i / j) == (i / j | i) && j * j != i) {
A += static_cast<long long>(C[i]) * C[i / j + i];
}
}
}
}
return A;
}
int main() {
initialize();
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> l(n);
for (int i = 0; i < n; ++i) {
cin >> l[i];
}
cout << s(l) << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 256ms
memory: 91308kb
input:
1 4 2 3 4 3
output:
done 2
result:
wrong output format Expected integer, but "done" found