Pagini recente » Cod sursa (job #3141279) | Cod sursa (job #2745705) | Cod sursa (job #2868975) | Cod sursa (job #2667641) | Cod sursa (job #1442192)
#include <cstdio>
#include <cstring>
#include <algorithm>
#define Nmax 4099
#define Mmax 65539
#define B 58
using namespace std;
long long a[Nmax][Nmax / B];
int i, j, n, m;
long long sol;
inline long long nb1(long long n)
{
int nb = 0;
if (n == 0) return 0;
do
{
n &= n - 1;
++ nb;
} while (n);
return nb;
}
void citire()
{
int x, y;
scanf("%d %d", &n, &m);
for (i = 1; i <= m ; ++ i)
{
scanf("%d %d", &x, &y);
for (j = 0; j <= n / B; ++ j)
sol += nb1(a[x][j] & a[y][j]);
a[x][y / B] += (1 << (y % B)) ;
a[y][x / B] += (1 << (x % B)) ;
}
}
int main()
{
freopen("triplete.in", "r", stdin);
freopen("triplete.out", "w", stdout);
citire();
printf("%lld", sol);
return 0;
}