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 ...
随机推荐
- java多线程总结一:线程的两种创建方式及比较
1.线程的概念:线程(thread)是指一个任务从头至尾的执行流,线程提供一个运行任务的机制,对于java而言,一个程序中可以并发的执行多个线程,这些线程可以在多处理器系统上同时运行.当程序作为一个应 ...
- 使用 ftrace 调试 Linux 内核,第 2 部分
ftrace 操作概述 使用 ftrace 提供的跟踪器来调试或者分析内核时需要如下操作: 切换到目录 /sys/kernel/debug/tracing/ 下 查看 available_tracer ...
- Louvain algorithm for community detection
主要理解Louvain 算法中对于模块度的定义:模块度是评估一个社区网络划分好坏的度量方法,它的物理含义是社区内节点的连边数与随机情况下的边数只差,它的取值范围是 [−1/2,1).可以简单地理解为社 ...
- BZOJ——1571: [Usaco2009 Open]滑雪课Ski
http://www.lydsy.com/JudgeOnline/problem.php?id=1571 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: ...
- T3139 栈练习3 codevs
http://codevs.cn/problem/3139/ 题目描述 Description 比起第一题,本题加了另外一个操作,访问栈顶元素(编号3,保证访问栈顶元素时或出栈时栈不为空),现在给出这 ...
- Java中循环与选择语句
public class Ifelse{ public static void main(String [] args){ int score=98; if(score>=90&& ...
- 【Java TCP/IP Socket】TCP Socket(含代码)
TCP的Java支持 协议相当于相互通信的程序间达成的一种约定,它规定了分组报文的结构.交换方式.包含的意义以及怎样对报文所包含的信息进行解析,TCP/IP协议族有IP协议.TCP协议和UDP协议.现 ...
- ClassLoader Java中类加载出现在哪个阶段,编译期和运行期? 类加载和类装载是一样的吗
1.ClassLoader Java中类加载出现在哪个阶段,编译期和运行期? 类加载和类装载是一样的吗? :当然是运行期间啊,我自己有个理解误区,改正后如下:编译期间编译器是不去加载类的,只负责编译而 ...
- [Testing] Static Analysis Testing JavaScript Applications
The static code analysis and linting tool ESLint is the de-facto standard for linting JavaScript pro ...
- 关于结构体的具体解说,C、C++中的差别
1. C.C++内置的类型分两种,一种是基本数据类型.一种是复合数据类型.此处我们要讲的结构体便是复合数据类型. 先来讨论一下结构体存在的意义吧.或许你觉得主要的数据类型就够了,为什么还要有结构题这样 ...