Pagini recente » Cod sursa (job #181982) | Cod sursa (job #2541414) | Cod sursa (job #2287469) | Cod sursa (job #1619560) | Cod sursa (job #46614)
Cod sursa(job #46614)
const b=32;
var x:array[1..4096,1..(4096 div b) +1]of longword;
f,g:text;
k,m,a1,a2,tri,l,n,c,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:=1 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)+1;
x[a1,c]:=x[a1,c] or (1 shl (a2 mod b));
c:=(a1 div b)+1;
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.