【最短路径-Dis】hdu 1596 find the safest road
来源:互联网 发布:联盟与协会的区别知乎 编辑:程序博客网 时间:2024/05/21 14:50
http://acm.hdu.edu.cn/showproblem.php?pid=1596
分析:乘积,注意初始化即可
#include<iostream>#include<cstdio>using namespace std;const int NM=1005;const int MAX=0;double a[NM][NM],p[NM];int n; bool flag[NM]; void Dis(int s,int t){int i,j,k; double mmin; memset(flag,0,sizeof(flag)); memset(p,0,sizeof(p)); // for(i=1;i<=n;i++) p[i]=a[s][i]; p[s]=1,flag[s]=1; // for(i=1;i<n;i++) { mmin=MAX; for(j=1;j<=n;j++) { if(!flag[j]&&mmin<p[j]) { k=j; mmin=p[j]; } } if(mmin==MAX) break; flag[k]=1; for(j=1;j<=n;j++) { if(!flag[j]&&p[j]<p[k]*a[k][j]) p[j]=p[k]*a[k][j]; } } if(p[t]>0) printf("%.3lf\n",p[t]);else printf("What a pity!\n");}int main(){int i,j,s,t,q;while(scanf("%d",&n)!=EOF){for(i=1;i<=n;i++){for(j=1;j<=n;j++)scanf("%lf",&a[i][j]);}scanf("%d",&q);for(i=0;i<q;i++){scanf("%d%d",&s,&t);Dis(s,t);}}return 0;}
- 【最短路径-Dis】hdu 1596 find the safest road
- hdu 1596 find the safest road(最短路径)
- [最短路径] HDU 1596 - find the safest road
- hdu 1596 find the safest road(最短路径,邻接矩阵)
- HDU find the safest road 最短路径 floyd
- hdoj 1596 find the safest road 【最短路径】
- hdu 题目1596 find the safest road (最短路径 dijkstra)
- Hdu 1596 find the safest road 变相最短路径 Dijstra算法
- HDU 1596 find the safest road (最短路径----dijkstra)
- HDU:1596 find the safest road(floyd最短路径算法+打表)
- hdu 1596 find the safest road (最短路径dijkstra SPFA Floyd)
- hdu1596 find the safest road(最短路径floyd)
- hdu 1596 find the safest road (最短路)
- HDU 1596 find the safest road 最短路求最大值
- HDU 1596find the safest road(最短路变形)
- hdu 1596 find the safest road(乘积最短路)
- HDU-1596-find the safest road(最短路)
- HDU 1596 find the safest road (最短路)
- 直方图均衡化
- 深入挖掘IOC、AOP以及Spring中的实现 .
- hdu2133
- 直方图规定化
- 2013多校联合训练第五场
- 【最短路径-Dis】hdu 1596 find the safest road
- HTML中<ul>标签中的<li>横向排列
- Java Atomic 包总结
- 30G 的redis 如何优化
- Webi-小技巧
- BadgeView使用介绍
- SQL Server 2008 R2 Reporting Service 登录权限不足的问题
- Netduino: 用Ethernet Shield读/写SD卡
- MyEclipse快捷键大全