poj 2253 最短路floyd **
题意:有两只青蛙和若干块石头,现在已知这些东西的坐标,两只青蛙A坐标和青蛙B坐标是第一个和第二个坐标,现在A青蛙想要到B青蛙那里去,并且A青蛙可以借助任意石头的跳跃,而从A到B有若干通路,问从A到B的所有通路上的最大边
链接:点我
floyd变形即可
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
#define pb(a) push_back(a)
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt,cnt;
struct Node
{
int x,y;
void in()
{
scanf("%d%d",&x,&y);
}
}node[MAXN];
double dis(Node a,Node b)
{
return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double dist[MAXN][MAXN]; int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
int ca=;
while(scanf("%d",&n)!=EOF)
{
if(n==) break;
for(i=;i<n;i++)
{
node[i].in();
}
cl(dist);
for(i=;i<n;i++)
{
for(j=;j<n;j++)
{
if(i==j) continue;
else dist[i][j]=dist[j][i]=dis(node[i],node[j]);
}
}
for(k=;k<n;k++)
{
for(i=;i<n;i++)
{
for(j=;j<n;j++)
{
if(dist[i][j]>max(dist[i][k],dist[k][j])) dist[i][j]=max(dist[i][k],dist[k][j]);
}
}
}
printf("Scenario #%d\nFrog Distance = %.3lf\n\n",ca++,dist[][]);
}
return ;
}
poj 2253 最短路floyd **的更多相关文章
- POJ 2253 Frogger(floyd)
http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...
- poj 2253 Frogger(floyd变形)
题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...
- POJ 2253 Frogger (Floyd)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions:57696 Accepted: 18104 Descript ...
- poj 2253 最短路 or 最小生成树
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- poj 2253 Frogger (最长路中的最短路)
链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...
- POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)
POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- POJ 2253 Frogger(dijkstra 最短路
POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...
随机推荐
- spring cloud 微服务架构 简介
Spring Cloud 1. Spring Cloud 简介 Spring Cloud是在Spring Boot的基础上构建的,用于简化分布式系统构建的工具集,为开发人员提供快速建立分布式系统中的 ...
- bzoj千题计划184:bzoj1261: [SCOI2006]zh_tree
http://www.lydsy.com/JudgeOnline/problem.php?id=1261 dp[l][r][dep] 区间[l,r]内的节点,根在dep层的最小代价 枚举根i,dp[ ...
- CSS3 - chrome,傲游,360极速浏览器不支持小于12px的字号的解决办法
google流量器chrome,傲游,360极速浏览器都是基于webkit内核浏览器,默认不支持小于font-size小于12px 的字号,即定义font-size小于12px时会发现字体大小依然是1 ...
- 第7月第12天 opengles background
1. After your app exits its applicationDidEnterBackground: method, it must not make any new OpenGL E ...
- CF293B 方格(带技巧的搜索)
solution: 首先我们根据一条路径上不能有两个相同颜色的格子可以得出: 对于两个格子 \((x_1 , y_1 )\) 和 \((x_2 , y_2 )\) 必须满足: \(x_1<x_2 ...
- requests(三):json请求中中文乱码处理
最近收到一个问题:json格式请求数据中有中文,导致服务端签名失败. 问题详情: 一位同学在发送json格式的post请求时,请求数据中有中文内容: {"inputCodes":[ ...
- python_ssh连接
首先下载paramikopip install paramiko查看并启动ssh服务service ssh status 添加用户:useradd -d /home/zet zetpasswd zet ...
- Windows修改默认远程端口号3389
1.打开注册表:运行-regedit: 2.HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Wds\Repwd\ ...
- MYSQL 添加外键报错
2014年6月16日 10:48:51 出错的部分提示摘录: #1452 - Cannot add or update a child row: a foreign key constraint fa ...
- 升级Chrome后无法打开网页
最近升级了网站,发现很多普通网站Chrome 都打不开了.... IE 可以正常打开,很是郁闷,重启电脑都不行. chrome://net-internals/#dns 点击如下按钮 清楚DNS缓 ...