Pagini recente » Cod sursa (job #679221) | Cod sursa (job #1988244) | Cod sursa (job #2231445) | Cod sursa (job #1827910) | Cod sursa (job #190256)
Cod sursa(job #190256)
#include <stdio.h>
struct relatie{
long x,y;
} b[65536];
unsigned long a[4096][128];
long n,m,i,j,x,y,nr;
int main()
{
freopen("triplete.in","r",stdin);
freopen("triplete.out","w",stdout);
scanf("%ld %ld\n",&n,&m);
for (i=1; i<=m; ++i)
{
scanf("%ld %ld\n",&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);
}
nr/=3;
printf("%ld\n", nr);
fclose(stdin); fclose(stdout);
return 0;
}