Pagini recente » Cod sursa (job #2970487) | Cod sursa (job #1205162) | Cod sursa (job #894656) | Cod sursa (job #1178723) | Cod sursa (job #610904)
Cod sursa(job #610904)
var a:array[1..500500] of longint;
n2,n,k:longint;
x2,y2:array[1..1000] of longint;
nr:int64;
i,j:longint;
f,g:text;
function pozitionare(st,dr:integer):integer;
var xst,xdr,aux:integer;
begin
xst:=0;
xdr:=-1;
while st<dr do
if a[st]<a[dr] then
begin
st:=st+xst;
dr:=dr+xdr;
end
else
begin
aux:=a[st];
a[st]:=a[dr];
a[dr]:=aux;
xst:=1-xst;
xdr:=-1-xdr;
st:=st+xst;
dr:=dr+xdr;
end;
pozitionare:=st;
end;
procedure quick(st,dr:integer);
var p:integer;
begin
p:=pozitionare(st,dr);
if st<p-1 then quick(st,p-1);
if p+1<dr then quick(p+1,dr);
end;
begin
assign(f,'trapez.in');reset(f);
assign(g,'trapez.out');rewrite(g);
read(f,n2);
for i:=1 to n2 do
read(f,x2[i],y2[i]);
n:=0;
for i:=1 to n2-1 do
for j:=i+1 to n2 do
begin
inc(n);
if (y2[i]-y2[j]>0) and (x2[i]-x2[j]>0)then
a[n]:=trunc((x2[i]-x2[j])/(y2[i]-y2[j])*100)
else
if (y2[i]-y2[j]=0) then a[n]:=0
else
a[n]:=9000;
end;
quick(1,n);
k:=0;
for i:=2 to n do
if a[i]=a[i-1] then inc(k)
else begin nr:=nr+k*(k+1) div 2;k:=0; end;
writeln(g,nr);
close(f);
close(g);
end.