Cod sursa(job #292939)

Utilizator AndreiDDiaconeasa Andrei AndreiD Data 31 martie 2009 20:25:04
Problema Triplete Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <stdio.h>

int a[1001][1001];
int n,m,nr,x,y,i,j,k;

int main()
{
    freopen("triplete.in","r",stdin);
    freopen("triplete.out","w",stdout);
    
    scanf("%d %d", &n,&m);
    for (i=1;i<=m;++i)
    {
         scanf("%d %d", &x,&y);
         a[x][y]=1;
         a[y][x]=1;
    }
    for (i=1;i<n-1;++i)
         for (j=i+1;j<n;++j)
               for (k=j+1;k<=n;++k)
                    if (a[i][j]==1 && a[i][k]==1 && a[j][k]==1)
                         nr++;
    printf("%d", nr);
    return 0;
}