Cod sursa(job #63318)

Utilizator alextheroTandrau Alexandru alexthero Data 27 mai 2007 19:49:31
Problema Medie Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <stdio.h>

#define nmax 9005
#define vmax 7005

int tot[vmax * 2],v[nmax],i,j,n,rez = 0;

int main() {
	freopen("medie.in","r",stdin);
	freopen("medie.out","w",stdout);

	scanf("%d",&n);
	for(int i = 1; i <= n; i++) {
		scanf("%d",&v[i]);
		for(int j = 1; j < i; j++) 
			if((v[i] + v[j]) % 2 == 0) tot[(v[i] + v[j]) / 2]++;
	}

	for(int i = 1; i <= n; i++) rez += tot[v[i]];

	printf("%d\n",rez);

	return 0;
}