type
bool=array[1..2000] of boolean;
var
n,i,p,k:integer;
x,y:array[1..2000] of extended;
nb:bool;
min:extended;
Function Check(nb:bool; n:integer):integer;
var
l,j,s:integer;
Begin
Check:=-1;
For l:=1 to n do
If nb[l]=False then
Begin
j:=j+1;
s:=l;
End;
If j=1 then
Begin
Check:=s;
p:=s;
End;
End;
Begin
ReadLn(n);
For i:=1 to n do
Read(x[n],y[n]);
For i:=2 to n do
If min>Sqrt(Sqr(x[1]-x[i])+Sqr(y[1]-y[i])) then
Begin
min:=Sqrt(Sqr(x[1]-x[i])+Sqr(y[1]-y[i]));
k:=i;
End;
nb[k]:=True;
Repeat
For i:=1 to n do
If nb[i]=False then
Begin
If min>Sqrt(Sqr(x[k+1]-x[i])+Sqr(y[k+1]-y[i])) then
Begin
min:=Sqrt(Sqr(x[k+1]-x[i])+Sqr(y[k+1]-y[i]));
k:=i;
End;
nb[k]:=True;
End;
Until Check(nb,n)<>-1;
WriteLn(p);
End.
Сообщение отредактировано: Perfez -