Pagini recente » Cod sursa (job #2108507) | Cod sursa (job #1577978) | Cod sursa (job #38282) | Cod sursa (job #2127149) | Cod sursa (job #1105291)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("medie.in");
ofstream g("medie.out");
int n,v[9005],s[15005],ap[15005];
long long sol=0;
int main()
{ int i,j;
f>>n;
for(i=1;i<=n;i++)
{f>>v[i];
ap[v[i]]++;
}
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
s[v[i]+v[j]]++;
for(i=1;i<=n;i++)
sol+=s[v[i]*2]-(ap[v[i]]-1)*(ap[v[i]]>1);
g<<sol;
return 0;
}