Pagini recente » Cod sursa (job #1259478) | Cod sursa (job #310968) | Cod sursa (job #2225390) | Cod sursa (job #2196467) | Cod sursa (job #218223)
Cod sursa(job #218223)
#include<stdio.h>
#define ll long long
int n,m,unde;
ll r=0;
unsigned char a[4098][515];
void citeste(int &x,int &y)
{
x=y=0;
char c[20];
fgets(c,20,stdin);
int i;
for(i=0; c[i]>='0' && c[i]<='9'; i++)
x=x*10+c[i]-'0';
for(i++; c[i]>='0' && c[i]<='9'; i++)
y=y*10+c[i]-'0';
}
void citire()
{
int x,y;
for(int i=0; i<m; i++)
{
citeste(x,y);
a[x][y>>3]|=1<<(y&7);
a[y][x>>3]|=1<<(x&7);
}
unde=(n>>3)+2;
//if(unde&7)
// unde++;
}
long long nrb(unsigned char x)
{
int k=0;
while(x)
{
x&=x-1;
k++;
}
ll k1=(ll)k;
return k1;
}
void vezi(int x,int y,int z)
{
unsigned char aux;
for(int i=0; i<unde; i++)
{
aux=a[x][i]&a[y][i]&a[z][i];
r+=nrb(aux);
}
}
int main()
{
freopen("triplete.in","r",stdin);
freopen("triplete.out","w",stdout);
scanf("%d%d\n",&n,&m);
citire();
int i,j,k;
for(i=1; i<=n; i++)
{
for(j=i+1; j<=n; j++)
{
for(k=j+1; k<=n; k++)
vezi(i,j,k);
}
}
printf("%lld\n",r);
return 0;
}