Pagini recente » Cod sursa (job #1858205) | Cod sursa (job #952076) | Cod sursa (job #141579) | Cod sursa (job #226092) | Cod sursa (job #12133)
Cod sursa(job #12133)
program triplete;
const b=60;
var
t:array[1..4096,0..312]of int64;
pow:array[0..b]of longint;
x,y:array[1..65536]of integer;
aux:integer;
n,m,i,j,k,nr,s:longint;
f:text;
begin
assign(f,'triplete.in');reset(f);
readln(f,n,m);
pow[0]:=1;
for i:=1 to b do
pow[i]:=pow[i-1] shl 1;
for i:=1 to m do begin
readln(f,x[i],y[i]);
aux:=y[i] div b;
t[x[i]][aux]:=t[x[i]][aux]+pow[y[i]-aux*b];
aux:=x[i] div b;
t[y[i]][aux]:=t[y[i]][aux]+pow[x[i]-aux*b];
end;
close(f);
k:=(n div b)+1;
for i:=1 to m do
for j:=0 to k do
begin
s:=t[x[i]][j] and t[y[i]][j];
while s<>0 do begin
if s xor 1<s then inc(nr);
s:=s shr 1;
end;
end;
assign(f,'triplete.out');rewrite(f);
write(f,nr div 3);
close(f);
end.