对于10%的数据 1<=N<=10
对于40%的数据 1<=N<=500 -10^5<=Ai<=10^5
对于70%的数据 1<=N<=5000 -10^6<=Ai<=10^6
对于100%的数据 1<=N<=5000 -10^9<=Ai<=10^9
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int hash[28301094],i,j,a,v[5000],k,ans;
bool p;
int ss(int);
bool pd(int);
int main()
{
freopen("good.in","r",stdin);
freopen("good.out","w",stdout);
scanf("%d",&a);
p=false;
for (i=1;i<=a;i++)
{
scanf("%d",&v[i]);
for (j=1;j<=i-1;j++)
{
k=v[i]-v[j];
if (k==0)
{
if (p==true)
{
ans++;
break;
}
}
else
if (pd(k)==true)
{
ans++;
break;
}
}
if (v[i]==0)
p=true;
for (j=1;j<=i;j++)
{
k=v[i]+v[j];
ss(k);
}
}
printf("%d",ans);
return 0;
}
int ss(int i)
{
int j;
j=i%14150547+14150547;
while ((hash[j]!=0)&&(hash[j]!=i))
{
j++;
if (j>28301094)
j=1;
}
hash[j]=i;
return 0;
}
bool pd(int i)
{
int j;
j=i%14150547+14150547;
while ((hash[j]!=0)&&(hash[j]!=i))
{
j++;
if (j>28301094)
j=1;
}
if (hash[j]==i) return true;
return false;
}