Pagini recente » Cod sursa (job #426087) | Cod sursa (job #2052648) | Cod sursa (job #2181108) | Cod sursa (job #257914) | Cod sursa (job #321949)
Cod sursa(job #321949)
// medie.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
int e[10000];
int ap[10000];
char c[100000];
unsigned int aparitii=0;
int el,n,md;
void parsare()
{
int x=0,nr=0;
fread(c,1,100000,stdin);
for(int i=0; c[i]!=EOF && c[i] ;i++)
if(c[i]=='\n')
{
e[++nr]=x;
ap[x]++;
x=0;
}
else
x=10*x+c[i]-'0';
if(x)
{
e[++nr]=x;
ap[x]++;
}
}
int main()
{
int i,j;
freopen("medie.in","r",stdin);
freopen("medie.out","w",stdout);
scanf("%d\n",&n);
parsare();
for(i=1;i<=n;++i)
for(j=i+1;j<=n;++j)
if((e[i]+e[j])>>1<<1==e[i]+e[j])
{
el=0;
md=(e[i]+e[j])>>1;
if(e[i]==md)
++el;
if(e[j]==md)
++el;
if(ap[md]-el>0)
aparitii=aparitii+ap[md]-el;
}
printf("%d",aparitii);
return 0;
}