记录编号 |
115711 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOI 2007]社交网络 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.047 s |
提交时间 |
2014-08-22 11:08:49 |
内存使用 |
0.47 MiB |
显示代码纯文本
- #include <iostream>
- #include <cstring>
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <algorithm>
- #include <queue>
- #include <stack>
- #include <map>
- #include <set>
- #include <list>
- #include <vector>
- #include <ctime>
- #include <iterator>
- #include <functional>
- #define pritnf printf
- #define scafn scanf
- #define For(i,j,k) for(int i=(j);i<=(k);(i)++)
- using namespace std;
- typedef long long LL;
- typedef unsigned int Uint;
- const int INF=10000000;
- //==============struct declaration==============
-
- //==============var declaration=================
- LL dist[101][101];
- LL way[101][101];
- //==============function declaration============
-
- //==============main code=======================
- int main()
- {
- string FileName="network1";//程序名
- string FloderName="COGS";//文件夹名
- freopen((FileName+".in").c_str(),"r",stdin);
- freopen((FileName+".out").c_str(),"w",stdout);
- #ifdef DEBUG
- system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
- #endif
- int n,m;
- int s,e,w;
- scanf("%d%d",&n,&m);
- For(i,1,n)
- {
- For(j,1,n)
- {
- dist[i][j]=INF;
- way[i][j]=1;
- }
- dist[i][i]=INF;
- }
- For(i,1,m)
- {
- scanf("%d%d%d",&s,&e,&w);
- dist[s][e]=dist[e][s]=w;
- }
- For(k,1,n)
- For(i,1,n)
- For(j,1,n)
- {
- if (i==j||i==k||j==k) continue;
- if (dist[i][k]+dist[k][j]<dist[i][j])
- {
- dist[i][j]=dist[i][k]+dist[k][j];
- way[i][j]=way[i][k]*way[k][j];
- }
- else if (dist[i][k]+dist[k][j]==dist[i][j])
- way[i][j]+=way[i][k]*way[k][j];
-
- }
- /*
- For(i,1,n)
- For(j,1,n)
- printf("%d-->%d minway->%d\n",i,j,way[i][j]);
- */
- For(v,1,n)
- {
- double I=0;
- For(s,1,n)
- For(e,1,n)
- if (dist[s][v]+dist[v][e]==dist[s][e])
- I+=double(way[s][v]*way[v][e])/way[s][e];
- printf("%.3lf\n",I);
- }
- return 0;
- }
- //================fuction code====================