Cod sursa(job #27836)

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



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

int a,b,j,k;

scanf("%d %d", &n, &m);
int 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("%d", tr);
return 0;
}