Pagini recente » Cod sursa (job #1739341) | Cod sursa (job #1354185) | Cod sursa (job #842886) | Cod sursa (job #2960519) | Cod sursa (job #190257)
Cod sursa(job #190257)
#include <stdio.h>
struct relatie{
long x,y;
} b[65600];
unsigned long a[5000][130];
long n,m,i,j,x,y,nr;
int main()
{
freopen("triplete.in","r",stdin);
freopen("triplete.out","w",stdout);
scanf("%ld %ld",&n,&m);
for (i=1; i<=m; ++i)
{
scanf("%ld %ld",&x,&y);
a[x][y >> 5]=a[x][y >> 5] | (1 << (y & 31));
a[y][x >> 5]=a[y][x >> 5] | (1 << (x & 31));
b[i].x=x; b[i].y=y;
}
nr=0;
for (i=1; i<=m; ++i)
for (j=0; j<=(n >> 5); ++j)
{
x=a[b[i].x][j] & a[b[i].y][j];
if (x!=0)
do {
x &=(x-1);
nr++;
}
while (x!=0);
}
nr/=3;
printf("%ld\n", nr);
fclose(stdin); fclose(stdout);
return 0;
}