QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#589989#858. GCD vs. XORayxrakzilWA 21ms9056kbC++14938b2024-09-25 20:56:072024-09-25 20:56:08

Judging History

This is the latest submission verdict.

  • [2024-09-25 20:56:08]
  • Judged
  • Verdict: WA
  • Time: 21ms
  • Memory: 9056kb
  • [2024-09-25 20:56:07]
  • Submitted

answer

#include <bits/stdc++.h>

const int N = 2e6 + 5, M = 1e6 + 5;

int t, n, a[N], b[M], ans;

int read() {
    int res = 0, i = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') i = -i;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    return res * i;
}

void write(int x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

void work() {
    n = read();
    for (int i = 1; i <= M - 5; ++i) b[i] = 0;
    ans = 0; 
    for (int i = 1; i <= n; ++i) a[i] = read(), ++b[a[i]];
    for (int d = 1; d <= M - 5; ++d)
        for (int x = d, y = x ^ d; x <= n; x += d, y = x ^ d)
            ans += b[x] * b[y];
    write(ans >> 1);
    puts("");
}

int main() {
    t = read();
    while (t--) work();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 9056kb

input:

1
4
2 3 4 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 7764kb

input:

20
43
128 66 452 384 400 441 232 203 228 33 284 156 128 190 197 292 388 31 179 343 147 206 450 284 180 73 273 130 168 250 405 203 235 340 309 28 267 395 152 191 295 463 344
54
48 7 12 37 49 24 5 18 15 37 26 57 53 59 22 10 2 16 36 52 64 1 56 42 38 46 53 7 2 8 60 38 54 11 19 50 20 61 6 50 27 5 26 3 4 ...

output:

0
60
2
2
0
19
25
0
0
124
1
0
10
0
1
0
4
411
1
0

result:

wrong answer 1st numbers differ - expected: '9', found: '0'