Pagini recente » Cod sursa (job #2873844) | Cod sursa (job #2583244) | Cod sursa (job #1715573) | Cod sursa (job #1469698) | Cod sursa (job #1875866)
#include <bits/stdc++.h>
#define hg 1<<10
#define verf ++poz == hg ? fin.read (ch, hg), poz = 0 : 0
#define fm 7001
#define nm 9001
using namespace std;
ifstream fin("medie.in");
ofstream fout("medie.out");
int fv[fm],v[nm],n,poz;
long long rez;
char ch[hg];
inline void read( int &x )
{
if (ch[0] == '\0') fin.read (ch, hg) ;
else for (; ch[poz] < '0' || ch[poz] > '9' ; verf) ;
for (x = 0 ; ch[poz] >= '0' && ch[poz] <= '9' ; x = x * 10 + ch[poz] - '0', verf) ;
}
int main()
{
int i,j;
read(n);
for(i=1;i<=n;i++)
{
read(v[i]);
fv[v[i]]++;
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(!((v[i]+v[j])%2))
{
rez+=fv[(v[i]+v[j])/2];
if(v[i]==v[j])
rez-=2;
}
}
}
fout<<rez;
fout.close();
return 0;
}