比赛 |
10101115 |
评测结果 |
WEWWEEEEEE |
题目名称 |
最小密度路径 |
最终得分 |
0 |
用户昵称 |
ZhouZn1 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-15 10:41:52 |
显示代码纯文本
program zzn;
var
n,m,i,j,x,y,z,q:longint;
a,w:array[1..50,0..50]of longint;
ans:double;
procedure init;
begin
assign(input,'path.in');
reset(input);
assign(output,'path.out');
rewrite(output);
fillchar(a,sizeof(a),0);
readln(n,m);
for i:=1 to m do
begin
readln(x,y,z);
inc(a[x,0]);
a[x,a[x,0]]:=y;
w[x,y]:=z;
end;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure dep(xx,bian,ww:integer);
var
i:integer;
begin
if xx=y then
begin
if ans>ww/bian then ans:=ww/bian;
exit;
end;
for i:=1 to a[xx,0] do
begin
dep(a[xx,i],bian+1,ww+w[xx,a[xx,i]]);
end;
end;
procedure main;
begin
ans:=maxlongint;
dep(x,0,0);
writeln(ans:0:3);
end;
begin
init;
readln(q);
for i:=1 to q do
begin
readln(x,y);
main;
end;
closef;
end.