QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752431#858. GCD vs. XORkangkunmaWA 256ms91308kbC++201.3kb2024-11-16 02:55:392024-11-16 02:55:39

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 02:55:39]
  • 评测
  • 测评结果:WA
  • 用时:256ms
  • 内存:91308kb
  • [2024-11-16 02:55:39]
  • 提交

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;
}

詳細信息

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