QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589981#858. GCD vs. XORayxrakzilWA 4ms7832kbC++14919b2024-09-25 20:54:162024-09-25 20:54:16

Judging History

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

  • [2024-09-25 20:54:16]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:7832kb
  • [2024-09-25 20:54:16]
  • 提交

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;
    for (int i = 1; i <= n; ++i) a[i] = read(), ++b[a[i]];
    for (int d = 1; d <= n; ++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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7832kb

input:

1
4
2 3 4 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 7704kb

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
62
64
64
83
108
108
108
233
234
234
244
244
245
245
249
661
662
662

result:

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