QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#23905#1842. MathDoorKickersTL 1022ms35100kbC++20535b2022-03-20 18:35:522022-04-30 04:24:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 04:24:15]
  • 评测
  • 测评结果:TL
  • 用时:1022ms
  • 内存:35100kb
  • [2022-03-20 18:35:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector<int> a(n + 1);
    map<int, int> cnt;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = a[i] + 1; j * j - a[i] * a[i] <= 1e6; j++) {
            ans += cnt[j * j - a[i] * a[i]];
        }
    }
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 2 3 4 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

5
6 4 7 3 5

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 13ms
memory: 6328kb

input:

50
89 2 3 86 81 59 29 26 28 8 48 5 6 95 54 91 17 83 4 36 15 43 92 70 30 37 23 96 39 80 9 90 49 82 33 71 61 38 99 50 65 47 78 45 68 7 25 42 13 57

output:

29

result:

ok 1 number(s): "29"

Test #5:

score: 0
Accepted
time: 256ms
memory: 22864kb

input:

1000
662 811 263 46 591 511 230 223 628 603 716 880 187 575 701 184 505 754 130 154 367 91 704 945 171 588 19 486 34 513 622 849 629 437 776 290 743 470 587 681 723 271 879 642 77 281 71 655 365 942 809 94 266 148 146 305 198 311 788 69 343 277 887 557 169 41 784 791 451 812 932 663 594 576 487 946 ...

output:

1750

result:

ok 1 number(s): "1750"

Test #6:

score: 0
Accepted
time: 1022ms
memory: 35100kb

input:

10000
2246 4941 6031 8713 4705 3744 9374 9432 2502 7080 8851 5408 4724 8905 7565 1699 6660 8959 7798 2287 4610 8806 8128 451 1355 2111 8775 4903 7517 8983 8144 2578 9565 7332 3213 4943 6520 616 2559 5573 6391 7148 5121 8395 5618 8733 6132 3717 8549 9651 1291 9462 5941 2342 9625 398 3916 8586 4290 26...

output:

23368

result:

ok 1 number(s): "23368"

Test #7:

score: -100
Time Limit Exceeded

input:

100000
94437 49936 62522 1166 33452 90618 91436 81173 99242 37280 46125 44869 52811 45694 11550 29857 48941 56538 35057 40907 79925 70785 29658 19044 32804 11428 4127 92197 12680 61636 27200 56790 83389 80340 54411 15308 38952 78085 81397 37554 44186 33581 35662 73331 84991 32044 69012 82289 63495 6...

output:


result: