hdu1596 find the safest road - floyd
2017-08-04 14:42:56
writer:pprp
题意:
第一行:n。n表示城市的个数n<=1000;
接着是一个n*n的矩阵表示两个城市之间的安全系数,(0可以理解为那两个城市之间没有直接的通道)
接着是Q个8600要旅游的路线,每行有两个数字,表示8600所在的城市和要去的城市
Output
其他的输出这两个城市之间的最安全道路的安全系数,保留三位小数。
算法分析:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath> using namespace std; const int maxn = ;
double dis[maxn][maxn];
int n; double MAX(double a,double b)
{
return a > b ?a:b;
} void floyd()
{
for(int k = ; k <= n; k++)
for(int i = ; i <= n ; i++)
for(int j = ; j <= n ; j++)
{
dis[i][j] = MAX(dis[i][j],dis[i][k]*dis[k][j]);
}
} int main()
{
while(scanf("%d",&n) != EOF)
{
memset(dis,,sizeof(dis)); for(int i = ; i <= n ; i++ )
for(int j = ; j <= n; j++)
scanf("%lf",&dis[i][j]); floyd(); int num;
int b, e;
scanf("%d",&num);
for(int i = ; i < num ; i++)
{
cin >> b >> e;
if(dis[b][e])
printf("%.3lf\n",dis[b][e]);
else
printf("What a pity!\n");
}
} return ;
}
hdu1596 find the safest road - floyd的更多相关文章
- HDU.1596 find the safest road (Floyd)
HDU.1596 find the safest road (Floyd) 题意分析 与普通的最短路不太相同,本题有些许的变化. 1. 要找到由i到j最安全的路,故在求解的时候要保证mp[i][j]尽 ...
- hdu1569find the safest road(floyd变形求最大安全值)
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- hdu1596find the safest road(floyd)
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU1596 find the safest road
find the safest road XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一 ...
- 杭电 1595 find the safest road
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 1596 find the safest road (最短路)
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU——1596find the safest road(邻接矩阵+优先队列SPFA)
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- 杭电1596 find the safest road
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- hdoj 1596 find the safest road【最短路变形,求最大安全系数】
find the safest road Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
随机推荐
- coreldraw X6 cdrX6下载激活工具
coreldraw X6 cdrX6下载激活工具 百度网盘 CDRX6下载 激活教程什么的请参考 低吟浅唱 博客
- SpringBoot专题1----springboot与mybatis的完美融合
springboot大家都知道了,搭建一个spring框架只需要秒秒钟.下面给大家介绍一下springboot与mybatis的完美融合: 首先:创建一个名为springboot-mybatis的ma ...
- Android性能测试摘入(TestHome)
Android性能测试: 客户端性能测试 服务端性能测试 客户端性能测试: 1.ROM版本的性能测试(即手机的不同操作系统):关注功耗测试 2.应用的性能测 ...
- 关于修改react的启动端口
在package.json文件里面,加一个port端口号就ok了
- 修改/etc/hosts 云服务器 没有做外网转内网的优化
[root@a mapReduceLog]# scp /data/visitlog/* root@d:/data/mapReduceVisitorLog/a/root@d's password:vis ...
- document.cookie = 'wcookie_date=' + wv + ';max-age=60'
js cookie生命周期
- PyMongo的使用(转)
原文:http://www.oschina.net/code/snippet_1382328_37407 #!/usr/bin/env python #coding:utf-8 # Author: - ...
- MySQL中的datetime与timestamp比较(转载)
原文地址:http://database.51cto.com/art/200905/124240.htm 相同 显示 TIMESTAMP列的显示格式与DATETIME列相同.换句话说,显示宽度固定在1 ...
- tensorflow 的 tutorial 的卷积神经网络的例子 convolutional.py
具体的网址在这里: https://github.com/tensorflow/tensorflow/tree/r0.12/tensorflow/models 一个卷积神经网络用于股票分析的例子: ...
- 其他机器访问本机redis服务器