Pagini recente » Cod sursa (job #727686) | Cod sursa (job #2952278) | Cod sursa (job #1633911) | Cod sursa (job #775582) | Cod sursa (job #1195597)
#include <iostream>
#include <fstream>
using namespace std;
long long int v[4096][64];
int nr_biti(long long int x)
{
int count = 0;
while(x)
{
x=x&(x-1);
count++;
}
return count;
}
ifstream fin("triplete.in");
ofstream fout("triplete.out");
int main ()
{
int n, m;
int a, b;
fin>>n>>m;
for(int i=0;i<m;i++)
{
fin>>a>>b;
a--;b--;
v[a][b>>6] |= 1LL<<(b%64);
v[b][a>>6] |= 1LL<<(a%64);
}
int count=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(v[i][j>>6]&(1LL<<(j%64)))
{
for(int k=0;k<64;k++)
{
count+=nr_biti(v[i][k] & v[j][k]);
}
}
}
}
fout<<count/3;
}