poj 1926
来源:互联网 发布:windows nt 6.1 编辑:程序博客网 时间:2024/06/06 04:16
#include<cstdio>#include<cstring>#include<vector>#include<algorithm>#define exp 1e-5using namespace std;vector<int>G[1600];double dp[2][160];double ABS(double a){if(a>0)return a;elsereturn -a;}int main(){int T;scanf("%d",&T);while(T--){ int n,m; scanf("%d%d",&n,&m);memset(dp,0,sizeof(dp)); for(int j=1;j<=120;j++)G[j].clear();for(int i=1;i<=n;i++)scanf("%lf",&dp[0][i]);for(int i=1;i<=m;i++){int a,b;scanf("%d%d",&a,&b);G[a].push_back(b);G[b].push_back(a);}int s=0;int tot=0;while(1){ s^=1; for(int j=1;j<=160;j++)dp[s][j]=0; for(int j=1;j<=n;j++){int num=G[j].size();if(num==0)dp[s][j]+=dp[s^1][j];for(int k=0;k<num;k++){int to=G[j][k];dp[s][to]+=dp[s^1][j]/num;}}int flag=0; for(int j=1;j<=n;j++) { if(ABS(dp[s][j]-dp[s^1][j])>exp) flag=1;} if(!flag)break;}for(int i=1;i<=n;i++)printf("%.3lf\n",dp[s][i]);printf("\n"); }}
0 0
- poj 1926
- Poj 1926 Pollution
- POJ 1926 Pollution
- poj 1926 Pollution
- POJ-1926 Pollution
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- HTTP和HTTPS的区别
- 算法提高 盾神与积木游戏
- 说说Python程序的执行过程
- Ubuntu中创建github远程仓库
- 51nod小c的多边形(找规律(构造))
- poj 1926
- ElasticSearch的一些删除用法笔记
- cache源码分析二 读写逻辑分析
- JS中的数组
- ie7下Ext-3.4打开iframe出现空白的问题
- 响应式网站
- Android Device Monitor 文件管理的常见问题
- 《55.1: Invited Paper: Video, Display and Processing》,译名:视频,显示器与处理
- centos7 修改DNS