Cod sursa(job #27840)

Utilizator RutZapGruia Radu RutZap Data 7 martie 2007 10:00:00
Problema Triplete Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <stdio.h>
long m,n,mat[1000][1000],tr=0;



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

int a,b,j,k;

scanf("%ld %ld", &n, &m);
long i;

for (i=1;i<=m;i++) {
			scanf("%d %d",&a,&b);
			mat[a][b]=1;
			mat[b][a]=1;
		       }


for (i=1;i<=n;i++)
  for (j=i+1;j<=n;j++)
	{
	if (mat[i][j]==1) for (k=j+1;k<=n;k++)
			 if ((mat[k][i]==1)&&(mat[k][j]==1)) tr++;
	}

printf("%ld", tr);
return 0;
}