Pagini recente » Cod sursa (job #2116330) | Cod sursa (job #2916942) | Cod sursa (job #758522) | Cod sursa (job #1468519) | Cod sursa (job #1396549)
#include <fstream>
using namespace std;
ifstream f("medie.in");
ofstream g("medie.out");
int a[9000],n,v[9000],f2[7000];
void cit()
{
f>>n;
int i;
for(i=1; i<=n; i++)
f>>a[i];
}
void rez()
{
int i,j,aux,s=0,p;
for(i=1; i<n; i++)
{
f2[a[i]]++;
for(j=i+1; j<=n; j++)
{
p=a[i]+a[j];
aux=(a[i]+a[j])/2;
if(aux*2==p)
v[aux]++;
}
}
f2[a[n]]++;
for(i=1; i<=n; i++)
if(v[a[i]]!=0)
s=s+v[a[i]]-f2[a[i]]+1;
g<<s;
}
int main()
{
cit();
rez();
return 0;
}