测评机: Xeost[5]
得分: 90分
提交日期: 2010-10-8 11:23:00
有效耗时: 1093毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时46ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 测试结果错误.错误结果为:6750.92 1.348991748413079E+292
正确结果应为:6750.92 1636.56
测试结果7: 通过本测试点|有效耗时156ms
测试结果8: 通过本测试点|有效耗时156ms
测试结果9: 通过本测试点|有效耗时156ms
测试结果10: 通过本测试点|有效耗时157ms
type
node=record
x,y:longint;
end;
var
a:array[1..100] of node;
i,j,n,k:longint;
lowcost:array[1..100] of real;
cloest:array[1..100] of longint;
sum,cost,min:real;
function len(x,y:longint):real;
begin
if x=y then exit;
len:=sqrt((a[y].x-a[cloest[y]].x)*(a[y].x-a[cloest[y]].x)
+(a[y].y-a[cloest[y]].y)*(a[y].y-a[cloest[y]].y));
len:=len+len(x,cloest[y]);
end;
begin
readln(n);
for i:=1 to n do
readln(a[i].x,a[i].y);
for i:=2 to n do
begin
lowcost[i]:=sqrt((a[1].x-a[i].x)*(a[1].x-a[i].x)
+(a[1].y-a[i].y)*(a[1].y-a[i].y));
cloest[i]:=1;
end;
for i:=1 to n-1 do
begin
min:=maxlongint;
for j:=1 to n do
if (lowcost[j]>0)and(lowcost[j]<min) then
begin
min:=lowcost[j];
k:=j;
end;
lowcost[k]:=0;
sum:=sum+min;
for j:=1 to n do
if lowcost[j]>0 then
begin
cost:=sqrt((a[k].x-a[j].x)*(a[k].x-a[j].x)
+(a[k].y-a[j].y)*(a[k].y-a[j].y));
if cost<lowcost[j] then
begin
lowcost[j]:=cost;
cloest[j]:=k;
end;
end;
end;
writeln(sum:0:2,' ',len(1,n):0:2);
end.