| 比赛 | 
    10101115 | 
    评测结果 | 
    AEWWEEEEEE | 
    | 题目名称 | 
    最小密度路径 | 
    最终得分 | 
    10 | 
    | 用户昵称 | 
    reamb | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2010-11-15 10:38:12 | 
显示代码纯文本
program zuixiaomidutu;
var
  q,n,m,i,a,x,y,b,step:longint;
  w,min:real;
  map:array[1..50,1..50]of real;
procedure sousuo(k:integer);
var
  i:longint;
begin
  for i:=1 to n do
    if map[k,i]>0 then
    begin
      step:=step+1;
      w:=w+map[k,i];
      if i=y then
      begin
        if w/step<min then
          min:=w/step
      end
      else
        sousuo(i);
      step:=step-1;
      w:=w-map[k,i]
    end;
end;
begin
  assign (input,'path.in');
  reset (input);
  assign (output,'path.out');
  rewrite (output);
    readln (n,m);
    for i:=1 to m do
    begin
      readln (a,b,w);
      map[a,b]:=w
    end;
    readln (q);
    for i:=1 to q do
    begin
      readln (x,y);
      step:=0;
      w:=0;
      min:=maxlongint;
      sousuo(x);
      if min=maxlongint then
        writeln ('OMG!')
      else
        writeln (min:0:3)
    end;
  close (input);
  close (output)
end.