记录编号 49440 评测结果 AAAAA
题目名称 小树 最终得分 100
用户昵称 Gravataro_o 是否通过 通过
代码语言 Pascal 运行时间 0.125 s
提交时间 2012-11-08 07:42:52 内存使用 3.99 MiB
显示代码纯文本
  1. var
  2. a,b,c,d,e,f,i,j,m,n,t,x,y,z:longint;
  3. o:real;
  4. k:array[0..1000,0..1000]of longint;
  5. procedure dfs(q,e,s:longint);
  6. var
  7. w:longint;
  8. begin
  9. for w:=1 to n do
  10. if (w<>q)and(k[q,w]<>0) then
  11. begin
  12. if o<(e+k[q,w])/(s+1) then
  13. o:=(e+k[q,w])/(s+1);
  14. dfs(w,e+k[q,w],s+1);
  15. end;
  16. end;
  17. begin
  18. assign(input,'treec.in');
  19. assign(output,'treec.out');
  20. reset(input);
  21. rewrite(output);
  22. readln(t);
  23. for a:=1 to t do
  24. begin
  25. o:=0;
  26. fillchar(k,sizeof(k),0);
  27. readln(n);
  28. for b:=1 to n-1 do
  29. begin
  30. readln(x,y,z);
  31. k[x,y]:=z;
  32. end;
  33. dfs(0,0,0);
  34. writeln(o:0:2);
  35. end;
  36. close(input);
  37. close(output);
  38. end.