讨论 / 为什么?
wyhbb163 2008-08-26 19:42:00
点我顶贴 收藏 删除
有四个点wa了。

program apple;

var

p:array[1..100,1..100] of extended;

a:array[1..100,1..2] of integer;

i,j,n,v,x,y,f,k,po:integer;

d,max,temp:extended;

c:array[1..100] of boolean;

begin

fillchar(c,sizeof(c),false);

////////////////////////////读取

readln(n,v);

for i:=1 to n do begin

readln(x,y,f);

a[i,1]:=x;

a[i,2]:=y;

if (i<>1) then begin

temp:=sqrt(sqr(x-a[f,1])+sqr(y-a[f,2]))/v;

if (temp<p[f,i]) or(p[f,i]=0)then p[f,i]:=temp;

end;

for j:=1 to i do begin

d:=sqrt(2*abs(y-a[j,2])/10);

if (x=a[j,1]) then begin

if (y>a[j,2]) then if (p[i,j]=0) or(d<p[i,j]) then p[i,j]:=d;

if (y<a[j,2]) then if (p[j,i]=0) or(d<p[j,i]) then p[j,i]:=d;

end;

end;

end;

//最短路

c[1]:=true;

for i:=1 to n-1 do begin

max:=maxint;

for j:=1 to n do begin

if (p[1,j]<>0)and(p[1,j]<max) and (c[j]=false) then begin

max:=p[1,j];

po:=j;

end;

end;

c[po]:=true;

for j:=1 to n do begin

if (p[po,j]<>0) and (not c[j]) then begin

if (p[po,j]+max<p[1,j]) or (p[1,j]=0) then p[1,j]:=p[po,j]+max;

end;

end;

end;

writeln(p[1,n]:0:2);

end.

#1 wyhbb163@2008-08-14 01:20:00
回复 删除
咋没牛来帮帮我呢?
#2 ithink@2008-08-26 19:42:00
回复 删除
好像比没有说能掉落到某点的比它高的点的序号一定比它小。可以读如完后,重新计算所有可能的掉落路径
查看更多回复
提交回复