QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#410511#1842. Mathiee#WA 91ms5796kbC++17649b2024-05-14 07:20:072024-05-14 07:20:08

Judging History

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

  • [2024-05-14 07:20:08]
  • 评测
  • 测评结果:WA
  • 用时:91ms
  • 内存:5796kb
  • [2024-05-14 07:20:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e6 + 5, inf = 2e6, B = 2000;
int n, a[N], cnt[N];
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	long long res = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] < B) {
			for (int j = 1; j <= n; j++) {
				int x = a[i] * a[i] + a[j];
				if ((int) sqrtl(x) * (int) sqrtl(x) == x) {
					res++;
				}
			}
		} else {
			long long x = 1ll * a[i] * a[i];
			long long y = sqrtl(x);
			if (y * y != x) y++;
			y *= y;
			y -= x;
			if (y < N) res += cnt[y];
		}
	}
	cout << res << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 2 3 4 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

5
6 4 7 3 5

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

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: 5ms
memory: 5796kb

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: -100
Wrong Answer
time: 91ms
memory: 5692kb

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:

19868

result:

wrong answer 1st numbers differ - expected: '23368', found: '19868'