#include <cstdio>#include<iostream>#include<cstring>#defineM 105using namespacestd;intn,m;Long LongD[m][m],sum[m][m];DoubleAns[m];intMain () {scanf ("%d%d",&n,&m); for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) D[i][j]=10000000001; for(intI=1; i<=m;i++) { inta1,a2; scanf ("%d%d",&a1,&A2); scanf ("%lld",&D[A1][A2]); D[A2][A1]=D[A1][A2]; SUM[A1][A2]=sum[a2][a1]=1; } for(intk=1; k<=n;k++) for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) { if(d[i][k]+d[k][j]<D[i][j]) {D[i][j]=d[i][k]+D[k][j]; SUM[I][J]=0; } if(d[i][k]+d[k][j]==D[i][j]) sum[i][j]+=sum[i][k]*Sum[k][j]; } for(intI=1; i<=n;i++) sum[i][i]=0; for(intk=1; k<=n;k++) for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) if(d[i][j]==d[i][k]+d[k][j]&&Sum[i][j]) ans[k]+ = (Sum[i][k]*sum[k][j])/(Double) Sum[i][j]; for(intI=1; i<=n;i++) printf ("%.3f\n", Ans[i]); return 0;}
Freud found the shortest distance between two points and how many schemes were used in Freud to judge each point on those shortest paths.
Bzoj 1491: [NOI2007] Social networks