poj 2253 Frogger 解题报告
题目链接:http://poj.org/problem?id=2253
题目意思:找出从Freddy's stone 到 Fiona's stone 最短路中的最长路。 很拗口是吧,举个例子。对于 i 到 j 的一条路径,如果有一个点k, i 到 k 的距离 && k 到 j 的距离都小于 i 到 j 的距离,那么就用这两条中较大的一条来更新 i 到 j 的距离 。每两点之间都这样求出路径。最后输出 1 到 2 的距离(1:Freddy's stone 2:Fiona's stone )。
只能说,读题能力有待改进啊~~~一开始也读不懂题意 = =
还有就是 sqrt 的参数不能是整数啦= =,要是double 或 float。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std; const int maxn = + ; struct node
{
double x, y;
}point[maxn]; double dist[maxn][maxn]; double distance(double x1, double x2, double y1, double y2)
{
double tx = x1 - x2;
double ty = y1 - y2;
return sqrt(tx*tx+ty*ty);
}
int main()
{
int n, l, f = , cas = ;
while (scanf("%d", &n) != EOF && n)
{
if (f)
puts("");
f = ;
for (l = ; l <= n; l++)
scanf("%lf%lf", &point[l].x, &point[l].y);
for (int i = ; i <= n; i++)
{
for (int j = i+; j <= n; j++)
dist[i][j] = dist[j][i] = distance(point[i].x, point[j].x, point[i].y, point[j].y);
}
// floyed
for (int k = ; k <= n; k++)
{
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
if (i != k && k != j && i != j && dist[i][j] > dist[i][k] && dist[i][j] > dist[j][k])
{
dist[i][j] = dist[j][i] = max(dist[i][k], dist[j][k]);
}
}
}
}
printf("Scenario #%d\n", ++cas);
printf("Frog Distance = %.3lf\n", dist[][]);
}
return ;
}
poj 2253 Frogger 解题报告的更多相关文章
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)
POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...
- POJ. 2253 Frogger (Dijkstra )
POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...
- POJ 2253 Frogger(dijkstra 最短路
POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...
- POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- POJ 2002 Squares 解题报告(哈希 开放寻址 & 链式)
经典好题. 题意是要我们找出所有的正方形.1000点,只有枚举咯. 如图,如果我们知道了正方形A,B的坐标,便可以推测出C,D两点的坐标.反之,遍历所有点作为A,B点,看C,D点是否存在.存在的话正方 ...
- poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))
传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- poj 2253 Frogger (dijkstra最短路)
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
随机推荐
- Scrapy学习-8-ItemLoader
ItemLoader使用 作用 方便管理维护重用xpath或css规则 实例 itemloader+图片处理 # items.py import scrapy from scrapy.loader ...
- Day 10 Linux nfs && crond(摘)
(摘) 介绍: NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布.功能是通过网络让不同的机器.不同的操作系 ...
- Netty和Akka有什么不同?
摘要: Akka is a concurrency framework built around the notion of actors and composable futures, Akka w ...
- TOT 傅立叶变换 FFT 入门
HDU 1402,计算很大的两个数相乘. FFT 只要78ms,这里: 一些FFT 入门资料:http://wenku.baidu.com/view/8bfb0bd476a20029bd642d85. ...
- Liunx 下Redis 的安装
一.Redis 的简介 Redis是一款开源的.高性能的键-值存储.它常被称作是一款数据结构服务器,它是一个key-value存储系统.和Memcache类似,Memecache只支持字符窜的数据类型 ...
- flask如何使模板返回大文件,又不消耗大量内存
当我们要往客户端发送大量的数据,比如一个大文件时,将它保存在内存中再一次性发到客户端开销很大.比较好的方式是使用流,本篇就要介绍怎么在Flask中通过流的方式来将响应内容发送给客户端.此外,我们还会演 ...
- DeepFM
DeepFM integrates the architectures of FM and deep neural networks (DNN). It models low-order featur ...
- IOS7 开发注意事项
1,修改状态栏的样式和隐藏. 首先,需要在Info.plist配置文件中,增加键:UIViewControllerBasedStatusBarAppearance,并设置为YES: 然后,在UIVie ...
- VMWare 14 Workstation Pro 下载与安装
1.双击安装运行 2.下一步 3.接受 下一步 4.自定义安装路径,下一步 5.下一步,取消勾选加入vmware客户体验 6.下一步 7.安装 8.安装中 9.完成 10.点击许可证安装 输入:FF3 ...
- <十二>读<<大话设计模式>>之状态模式
对于状态模式,<<大话设计模式>>是以人从上班到下班到加班的状态来展开讲述的.状态模式事实上就是某一个对象在某个过程或者时间的一个状态记录,可是这个状态的顺序不能发生变化.在程 ...