Pagini recente » Cod sursa (job #2363594) | Cod sursa (job #2397129) | Cod sursa (job #267898) | Cod sursa (job #2416972) | Cod sursa (job #46568)
Cod sursa(job #46568)
{triplete}
const b=32;
max=4096;
var x:array[1..max,1..max div b] of longword;
t:longword;
m,n,i,j,total,pas,p1,p2:integer;
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.