QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559784#1842. Mathydzr00000WA 5ms3976kbC++17403b2024-09-12 09:21:142024-09-12 09:21:16

Judging History

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

  • [2024-09-12 09:21:16]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3976kb
  • [2024-09-12 09:21:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int buf[1000001];
const int V=1e6;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		buf[x]++;
	}
	long long ans=0;
	for(int i=1;i<=V;i++)
		for(int j=i+1;j<=V;j++)
		{
			long long diff=1ll*j*j-1ll*i*i;
			if(diff>V)
				break;
			ans=ans+buf[diff];
		}
	printf("%lld\n",ans);

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3916kb

input:

5
1 2 3 4 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 5ms
memory: 3976kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

5
6 4 7 3 5

output:

3

result:

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