QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559784 | #1842. Math | ydzr00000 | WA | 5ms | 3976kb | C++17 | 403b | 2024-09-12 09:21:14 | 2024-09-12 09:21:16 |
Judging History
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'