hdu1596find the safest road(floyd)
find the safest road
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16965 Accepted Submission(s): 5876
第一行:n。n表示城市的个数n<=1000;
接着是一个n*n的矩阵表示两个城市之间的安全系数,(0可以理解为那两个城市之间没有直接的通道)
接着是Q个8600要旅游的路线,每行有两个数字,表示8600所在的城市和要去的城市
其他的输出这两个城市之间的最安全道路的安全系数,保留三位小数。
题意:给出一个矩阵,里面两个城市之间的安全系数,之后给出数对城市,要求输出最大的安全系数
题解:floyd入门。
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
double a[][];
int n;
void floyd() {
for(int k=; k<=n; k++) {
for(int i=; i<=n; i++) {
for(int j=; j<=n; j++) {
a[i][j]=max(a[i][j],a[i][k]*a[k][j]);
}
}
}
}
int main() { while(~scanf("%d",&n))
{
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
scanf("%lf",&a[i][j]);
}
}
floyd();
int q;
scanf("%d",&q);
while(q--)
{
int x,y;
scanf("%d %d",&x,&y);
if(a[x][y]==)printf("What a pity!\n");
else
printf("%.3lf\n",a[x][y]);
}
}
return ;
}
hdu1596find 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 ...
- hdu1596 find the safest road - floyd
2017-08-04 14:42:56 writer:pprp 题意: Problem Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每 ...
- 杭电 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 ...
- find the safest road
find the safest road Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Othe ...
随机推荐
- Avito Cool Challenge 2018 B. Farewell Party 【YY】
传送门:http://codeforces.com/contest/1081/problem/B B. Farewell Party time limit per test 1 second memo ...
- VMware12上安装CentOS无法上网问题
进入/etc/sysconfig/network-scripts目录下,查看有没有ifcfg-XXX的文件(ifcfg-lo除外), 没找到网卡设备,原因:由于Vmware虚拟网卡和Linux兼容问题 ...
- python2.7 安装Django
目前Django最新版是2.0,不支持Python2,在使用pip 安装的时候会报错,pip默认安装的是最新的稳定版本 使用pip指定安装的版本:pip install django==1.11.4 ...
- iOS之序列化与反序列化
所谓的序列化和反序列化就是将数据结构或对象和二进制串之间相互转换的过程: 本人的理解是当你于写数据需要本地存储时,即将你的数据写到硬盘上的时候,你就必须对他进行序列化,转换成二进制文件,从而便于在磁盘 ...
- Gradle Goodness: Check Task Dependencies With a Dry Run
We can run a Gradle build without any of the task actions being executed. This is a so-called dry ru ...
- Parallel.ForEach使用示例
新建一个.NET Core控制台程序,代码如下: using System; using System.Collections.Generic; using System.Threading; usi ...
- 使用 input[type=file]上传文件
var $file = $('#file'); $('#btn').click(function() { var data = new FormData(); data.append('file', ...
- SSM整合时初始化出现异常
java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException ...
- Django学习笔记1
重点在注释# 1.views.py from django.shortcuts import render from django.http import * #from django.templat ...
- ps命令 百度+加自己的理解
ps故为process status的缩写,即为进程状态的命令, ps命令详解, 1)ps a 显示现行终端机下的所有程序,包括其他用户的程序.2)ps -A 显示所有程序.3)ps c 列出程序时, ...