Pagini recente » Cod sursa (job #1672688) | Cod sursa (job #399209) | Cod sursa (job #3239520) | Cod sursa (job #1854215) | Cod sursa (job #190267)
Cod sursa(job #190267)
#include <stdio.h>
#include <strings>
struct relatie{
long x,y;
} b[65600];
unsigned long a[5000][130];
long n,m,i,j,x,y,nr;
char s[20];
int cit(long *x,*y)
{
fgets(s,20,stdin);
int lung=strlen(s)-1;
x=0;
for ( ; (s[i]!=' ') && (i<lung); ++i)
x=x*10+s[i]-48;
++i;
y=0;
for ( ; (s[i]!=' ') && (i<lung); ++i)
x=x*10+s[i]-48;
}
int main()
{
freopen("triplete.in","r",stdin);
freopen("triplete.out","w",stdout);
cit(n,m);
for (i=1; i<=m; ++i)
{
cit(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;
}