Pagini recente » Cod sursa (job #1235116) | Cod sursa (job #2418675) | Cod sursa (job #1569637) | Cod sursa (job #2982302) | Cod sursa (job #324093)
Cod sursa(job #324093)
var f,g:text;
a1,a2:array[1..65536] of longint;
a:array[0..4096,0..1000] of integer;
n,m,i,j,s,x,y:longint;
function nr(i:integer):byte;
var
num:byte;
int:integer;
begin
num:=0;
int:=i;
while i<>0 do begin
inc(num);
i:=i and (i-1);
end;
nr:=num;
end;
begin
assign(f,'triplete.in');
reset(f);
assign(g,'triplete.out');
rewrite(g);
read(f,n,m);
for i:=1 to m do begin
read(f,x,y);
dec(x);
dec(y);
a[x,y shr 4]:=a[x,y shr 4] or (1 shl (y and 15));
a[y,x shr 4]:=a[y,x shr 4] or (1 shl (x and 15));
a1[i]:=x;
a2[i]:=y;
end;
for i:=1 to m do
for j:=0 to (n-1) shr 4 do
inc(s,nr(a[a1[i],j] and a[a2[i],j]));
writeln(g,s div 3);
close(f);
close(g);
end.