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 ...
随机推荐
- Struts2_day01
一.内容大纲 1 struts2概述 (1)应用在web层 2 struts2入门案例 3 struts2底层执行过程 4 struts2相关配置 (1)struts.xml配置 - package. ...
- mysql统计一个字段的多种状态
假如我有下面的表:ID Item status updatetime author1 a 1 2014-01-0 ...
- C++ socket 网络编程 简单聊天室
操作系统里的进程通讯方式有6种:(有名/匿名)管道.信号.消息队列.信号量.内存(最快).套接字(最常用),这里我们来介绍用socket来实现进程通讯. 1.简单实现一个单向发送与接收 这是套接字的工 ...
- lucene入门查询索引——(三)
1.用户接口(lucene不提供)
- CVTE笔试题
一.题目 给定一个数组a[N],我们希望构造数组b [N],其中b[j]=a[0]*a[1]…a[N-1] / a[j],在构造过程中,不允许使用除法: 要求O(1)空间复杂度和O(n)的时间复杂度: ...
- linux动态追踪神器——Strace实例介绍【转】
Strace是Linux下一款通用的进程动态跟踪工具,用来追踪程序执行时的系统调用和所接收的信号.其应用方法如下图(部分). 首先,简单说说它的使用参数,Strace的参数包括输出参数.过滤参数.统计 ...
- IE浏览器如何调试Asp.net的 js代码
不管我们开发什么项目,都需要使用调试.后端的调试比较简单.前端js调试稍微复杂了一点,但是也别怕,因为我们有很多调试前端js代码的浏览器工具.比如IE浏览器.firefox浏览器.chrome浏览器等 ...
- springcloud服务安全连接
Spring Cloud可以增加HTTP Basic认证来增加服务连接的安全性. 1.加入security启动器 在maven配置文件中加入Spring Boot的security启动器. <d ...
- trove远程连接mongodb
创建数据库 <pre> [root@a581c7388dca /]# trove database-create e50f3b40-5165-4ccc-af9f-c121089fd902 ...
- js 替换任意字符串中间几位为*星号
<script> var str='河南纳智企业管理咨询有限公司'; a=str.substr(0,2)+'***'+str.substr(5,str.split('').length); ...