Pagini recente » Cod sursa (job #2866138) | Cod sursa (job #2751074) | Cod sursa (job #1866941) | Cod sursa (job #99409) | Cod sursa (job #37356)
Cod sursa(job #37356)
var f:text;
x,y:array[0..50000] of extended;
lrx,lry,rx,ry,jump:extended;
h:array[0..4] of extended;
n,i,j:word;
function get(rx,ry:extended):extended;
var i:word;
sol:extended;
begin
sol:=0;
for i:=1 to n do
sol:=sol+sqrt(sqr(rx-x[i])+sqr(ry-y[i]));
get:=sol;
end;
begin
assign(f,'adapost2.in');
reset(f);
read(f,n);
for i:=1 to n do
begin
read(f,x[i],y[i]);
rx:=rx+x[i];
ry:=ry+y[i];
end;
close(f);
rx:=rx/n;
ry:=ry/n;
h[0]:=get(rx,ry);
jump:=1000;
while (jump>0.00001) do
begin
h[1]:=get(rx+jump,ry);
h[2]:=get(rx-jump,ry);
h[3]:=get(rx,ry-jump);
h[4]:=get(rx,ry+jump);
j:=0;
for i:=1 to 4 do
if h[i]<h[j] then j:=i;
h[0]:=h[j];
if j=1 then rx:=rx+jump;
if j=2 then rx:=rx-jump;
if j=3 then ry:=ry-jump;
if j=4 then ry:=ry+jump;
jump:=jump/2;
end;
assign(f,'adapost2.out');
rewrite(f);
writeln(f,rx:0:4,' ',ry:0:4);
close(f);
end.