POJ-2253-Frogger
来源:互联网 发布:学摄影的书籍知乎 编辑:程序博客网 时间:2024/05/24 04:48
Description
Unfortunately Fiona's stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
You are given the coordinates of Freddy's stone, Fiona's stone and all other stones in the lake. Your job is to compute the frog distance between Freddy's and Fiona's stone.
Input
Output
Sample Input
20 03 4317 419 418 50
Sample Output
Scenario #1Frog Distance = 5.000Scenario #2Frog Distance = 1.414
Source
题目大概的意思就是然你求最短路径中的最长的两点间的距离,是一个Flody的变型
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
double Distance[210][210];
struct node
{
double x,y;
}a[210];
int main()
{
int n,t=1,i,j,k;
while(~scanf("%d",&n)&&(n!=0))
{
memset(a,0,sizeof(a));
memset(Distance,0,sizeof(Distance));
for(i=0;i<n;i++)
{
scanf("%lf %lf",&a[i].x,&a[i].y);
}
求两点间的距离
for(i=0;i<n;i++)
for(j=0;j<n;j++)
Distance[i][j]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
flody的变型
for(k=0;k<n;k++)
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(Distance[i][j]>Distance[i][k]&&Distance[i][j]>Distance[k][j])
{
Distance[i][j]=max(Distance[i][k],Distance[k][j]);
}
printf("Scenario #%d\n",t);
printf("Frog Distance = %.3lf\n\n",Distance[0][1]);
t++;
}
return 0;
}
- poj 2253 - Frogger --- SPFA
- poj 2253 - Frogger --- dijkstra
- POJ 2253 Frogger
- poj 2253 Frogger
- poj 2253 Frogger
- poj 2253 Frogger
- POJ 2253 Frogger Floyd
- poj 2253 : Frogger (dijkstra)
- Poj 2253 Frogger
- POJ 2253 Frogger
- poj 2253 Frogger
- poj 2253 Frogger
- poj 2253 Frogger
- poj 2253 Frogger
- poj-2253-Frogger
- POJ 2253 Frogger
- POJ 2253 Frogger
- POJ 2253 Frogger
- NetBeans打开外部项目时出现Project needed to be updated SDk tools
- windbg安装mona.py插件
- 程序员发现 Bug 的时候是怎样一种心境?
- 数据结构看书笔记(一)--数据结构简介
- React子组件修改父组件的状态
- POJ-2253-Frogger
- MFC文档/视图结构体系及SDI回顾(2)
- 程序员最害怕的5件事,你中招了吗?
- destoon通过修改源代码实行及时订单处理在线支付
- 安装jpype出现_jpype错误的解决方案
- equals与==之间的区别
- 使用Spring(二)实例化方式(静态工厂,实例工厂)
- The Log(我所读过的最好的一篇分布式技术文章)
- 从“鞭打快牛”故事来看团队的领导力