Pagini recente » Cod sursa (job #130879) | Cod sursa (job #2641091) | Cod sursa (job #3033261) | Cod sursa (job #2049528) | Cod sursa (job #46589)
Cod sursa(job #46589)
const b=32;
var x:array[1..4096,0..32]of longword;
f,g:text;
k,m,i,j,a1,a2,tri,l,n,c,r,t:word;
begin
assign(f,'triplete.in');
reset(f);
read(f,n,m);
if (n mod b <>0)then
n:=(n div b)+1
else
n:=n div b;
tri:=0;
for k:=1 to m do
begin
read(f,a1,a2);
for t:=0 to n do
begin
l:=x[a1,t] and x[a2,t];
while(l>0)do
begin
l:=l and(l-1);
tri:=tri+1;
end;
end;
c:=a2 div b;
x[a1,c]:=x[a1,c] or (1 shl (a2 mod b));
c:=a1 div b;
x[a2,c]:=x[a2,c] or (1 shl(a1 mod b));
end;
close(f);
assign(g,'triplete.out');
rewrite(g);
writeln(g,tri);
close(g);
end.