Pagini recente » Cod sursa (job #2618525) | Cod sursa (job #1616672) | Cod sursa (job #2353780) | Cod sursa (job #864616) | Cod sursa (job #12677)
Cod sursa(job #12677)
var fi,fo:text;
i,n,j,x,y,aux:longint;
rez,bla,m:longint;
xx,yy:array[0..1 shl 16-1]of longint;
nr:array[0..1 shl 16-1]of integer;
mat:array[0..4096,0..4096 div 31]of longint;
begin
assign(fi,'triplete.in'); reset(fi);
assign(fo,'triplete.out'); rewrite(fo);
readln(fi,n,m);
for i:=0 to m-1 do
begin
readln(fi,x,y);
mat[x,y div 31]:=mat[x,y div 31]or (1 shl(y mod 31));
mat[y,x div 31]:=mat[y,x div 31]or (1 shl(x mod 31));
xx[i]:=x; yy[i]:=y;
end;
for i:=1 to (1 shl 16-1) do
nr[i]:=nr[i shr 1]+i and 1;
rez:=0; aux:=n div 31;
for i:=0 to m-1 do
for j:=0 to aux do
begin
bla:=mat[xx[i],j]and mat[yy[i],j];
inc(rez,nr[bla shr 15]+nr[bla and(1 shl 15-1)]);
end;
writeln(fo,rez div 3);
close(fo);
end.