题目链接: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 解题报告的更多相关文章

  1. 最短路(Floyd_Warshall) POJ 2253 Frogger

    题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...

  2. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  3. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

  4. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  5. POJ 2253 Frogger

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  6. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  7. POJ 2002 Squares 解题报告(哈希 开放寻址 & 链式)

    经典好题. 题意是要我们找出所有的正方形.1000点,只有枚举咯. 如图,如果我们知道了正方形A,B的坐标,便可以推测出C,D两点的坐标.反之,遍历所有点作为A,B点,看C,D点是否存在.存在的话正方 ...

  8. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  9. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

随机推荐

  1. HDU 5009 Paint Pearls(西安网络赛C题) dp+离散化+优化

    转自:http://blog.csdn.net/accelerator_/article/details/39271751 吐血ac... 11668627 2014-09-16 22:15:24 A ...

  2. ZOJ - 3816 Generalized Palindromic Number dfs

    Generalized Palindromic Number Time Limit: 2 Seconds                                     Memory Limi ...

  3. iOS常用三方库收集

    除非Pod可以直接加载到工程中的外,收集一下 https://github.com/kejinlu/KKGestureLockView          好用的手势解锁

  4. Scrapy学习-1-入门

    基础知识 爬虫发展史   爬虫去重 1. 存储到数据库中 存取速度慢 2. 存储到内存中的集合里,内存占用十分大 当爬取数据有1亿条时 1*10**8*2Byte*50str_len/1024/102 ...

  5. db2数据备份与恢复

    备份:先关掉所有tomcat运行:db2cmd db2Stop force db2Start DB2 FORCE APPLICATIONS ALL DB2 BACKUP DATABASE histes ...

  6. ubuntu下安装jdk、tomcat、mysql

    1.JDK安装 方法1: 将JDK安装包解压缩之后,编辑~/.bashrc文件,在该文件里面加入下面的配置,然后通过source ~/.bashrc.JDK即安装成功. export JAVA_HOM ...

  7. android DatePicker使用

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...

  8. Mysql 性能优化20个原则(1)

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  9. jmeter Plugins Manager插件管理

    在 https://jmeter-plugins.org/downloads/all/ 下载插件,放到lib/ext Download plugins-manager.jar and put it i ...

  10. [转]gzip,bzip2,tar,zip命令使用方法详解

    原文:http://blog.chinaunix.net/uid-20779720-id-2547669.html 1 gzipgzip(1) 是GNU的压缩程序.它只对单个文件进行压缩.基本用法如下 ...