Pagini recente » Cod sursa (job #24397) | Cod sursa (job #767976) | Cod sursa (job #2267675) | Cod sursa (job #758229) | Cod sursa (job #12671)
Cod sursa(job #12671)
var fi,fo:text;
m,i,bla:longint;
n,j,x,y,aux:integer;
rez:longint;
xx,yy:array[0..1 shl 16]of word;
nr:array[0..1 shl 17]of word;
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:=1 to m 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 66000 do
nr[i]:=nr[i shr 1]+i and 1;
rez:=0; aux:=n div 31;
for i:=1 to m 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.