比赛 |
10101115 |
评测结果 |
WWWWWWWWWW |
题目名称 |
最小密度路径 |
最终得分 |
0 |
用户昵称 |
1102 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-15 10:42:31 |
显示代码纯文本
program xxxxx;
var n,m,max,i,j,k,q,a,a1,a2:longint;
f:array[1..50,1..50,1..2] of longint;
begin
assign(input,'path.in');
reset(input);
assign(output,'path.out');
rewrite(output);
read(n,m);
max:=maxlongint;
for i:=1 to n do
for j:=1 to n do
begin
f[i,j,1]:=max;
f[i,j,2]:=0;
end;
for i:=1 to m do
begin
read(a,a1,a2);
f[a,a1,1]:=a2;
f[a,a1,2]:=1;
end;
for i:=1 to n do
for j:=1 to n do
for k:=1 to n do
if (f[i,j,1]<max)and(f[j,k,1]<max) then
if (f[i,k,2]=0)or((f[i,j,1]+f[j,k,1])/(f[i,j,2]+f[j,k,2])<f[i,k,1]/f[i,k,2]) then
begin
f[i,k,1]:=f[i,j,1]+f[j,k,1];
f[i,k,2]:=f[i,j,2]+f[j,k,2];
end;
read(q);
for i:=1 to q do
begin
read(a,a1);
if f[a,a1,1]<max then
writeln(f[a,a1,1]/f[a,a1,2]:0:3)
else
writeln('OMG!');
end;
close(input);
close(output);
end.