Pagini recente » Cod sursa (job #2717386) | Cod sursa (job #369037) | Cod sursa (job #159583) | Cod sursa (job #943120) | Cod sursa (job #46592)
Cod sursa(job #46592)
{triplete}
const b=32;
max=10000;
var x:array[1..max,1..max div b+1] of longword;
t:longword;
m,n,i,j,total,pas,p1,p2:longword;
f:text;
begin
assign(f,'triplete.in'); reset(f);
readln(f,n,m);
pas:=n div b;
if n mod b<>0 then
inc(pas);
total:=0;
for i:=1 to m do begin
readln(f,p1,p2);
for j:=1 to pas do begin
t:=x[p1,j] and x[p2,j];
while t <> 0 do begin
t:= (t and (t-1));
inc(total);
end;
end;
t:=(p2 div b) +1;
x[p1,t]:=x[p1,t] or (1 shl (p2 mod b));
t:=(p1 div b) +1;
x[p2,t]:=x[p2,t] or (1 shl (p1 mod b));
end;
close(f);
assign(f,'triplete.out'); rewrite(f);
writeln(f,total);
close(f);
end.