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 ...
随机推荐
- 【BZOJ3166】[Heoi2013]Alo 可持久化Trie树+set
[BZOJ3166][Heoi2013]Alo Description Welcome to ALO ( Arithmetic and Logistic Online).这是一个VR MMORPG , ...
- hdu 4512 吉哥系列故事——完美队形I【LCIS经典应用】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4512 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- 储存应用程序的配置信息ini实现方式
1.C语言中文件操作.2.C++语言中的文件操作.3.Win32 API函数文件操作.4.MFC CFile类文件操作.5.MFC CFileDialog类的文件操作.6.注册表文件操作. 下面我来详 ...
- mysql几种引擎和使用场景
https://blog.csdn.net/cool_wayen/article/details/79585277 数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建. ...
- Java基础语法 - 面向对象 - 类的主方法main方法
主方法是类的入口点,它指定了程序从何处开始,提供对程序流向的控制.Java编译器通过主方法来执行程序. 主方法的语法如下: /* a.主方法是静态的,如果要直接在主方法中调用其它方法,则该方法必须也是 ...
- python基础之类的进阶
一.__setitem__,__getitem,__delitem__ #把对象操作属性模拟成字典的格式 class Foo: def __init__(self,name): self.name=n ...
- mongoose学习
#mongoose的使用详解# ##1.Scheme.model和Entity## Schema : 一种以文件形式存储的数据库模型骨架,不具备数据库的操作能力 Model : 由Schema发布生成 ...
- git 添加远程仓库后无法push
push的时候提示fatal: refusing to merge unrelated histories 假如我们的源是origin,分支是master,那么我们 需要这样写git pull o ...
- JS产品分类列表练习
CSS: ;;} ul,li{list-style: none;} body{color: #666;background: #f5f5f5;} a{text-decoration: none;col ...
- Redis持久化方式RDB和AOF
Redis 持久化 RDB(快照) 优点 rdb是可进行压缩的二进制文件,表示Redis在某一个时间点的数据快照.非常使用与备份,灾难恢复等场景.比如使用定时任务执行bgsave并备份rdb到serv ...