标签:
为1
1 var 2 i,j,k,l,m,n,s,t:longint; 3 a,b:array[0..150,0..150] of int64; 4 c:array[0..150] of int64; 5 d:array[0..150] of extended; 6 begin 7 readln(n,m); 8 fillchar(a,sizeof(a),0); 9 fillchar(b,sizeof(b),0); 10 for i:=1 to n do b[i,i]:=1; 11 for i:=1 to m do 12 begin 13 readln(j,k,l); 14 a[j,k]:=l;a[k,j]:=l; 15 b[j,k]:=1;b[k,j]:=1; 16 end; 17 for k:=1 to n do 18 for i:=1 to n do 19 begin 20 if (i<>k) and (a[i,k]>0) then 21 begin 22 for j:=1 to n do 23 begin 24 if (i<>j) and (j<>k) and (a[k,j]>0) then 25 begin 26 if ((a[k,j]+a[i,k])=a[i,j]) then 27 begin 28 b[i,j]:=b[i,j]+(b[i,k]*b[k,j]); 29 end 30 else 31 begin 32 if ((a[k,j]+a[i,k])<a[i,j]) or (a[i,j]=0) then 33 begin 34 a[i,j]:=a[k,j]+a[i,k]; 35 b[i,j]:=b[i,k]*b[k,j]; 36 end; 37 end; 38 end; 39 end; 40 end; 41 end; 42 fillchar(d,sizeof(d),0); 43 for s:=1 to n do 44 for t:=1 to n do 45 begin 46 if s=t then continue; 47 fillchar(c,sizeof(c),0); 48 for i:=1 to n do 49 begin 50 if (s=i) or (t=i) then continue; 51 if (a[s,i]+a[i,t])<>a[s,t] then continue; 52 d[i]:=d[i]+(b[s,i]*b[i,t])/b[s,t]; 53 end; 54 end; 55 for i:=1 to n do writeln(d[i]:0:3); 56 end.
标签:
原文地址:http://www.cnblogs.com/HansBug/p/4176833.html