解决报告

意甲冠军:

乞讨0至1所有最大的道路值的最小数量。

思维:

floyd。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define inf 0x3f3f3f3f
using namespace std;
int n,m,q;
double mmap[210][210];
struct node {
double x,y;
} p[210];
double dis(node p1,node p2) {
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
void floyd() {
for(int k=0; k<n; k++)
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
mmap[i][j]=min(mmap[i][j],max(mmap[i][k],mmap[k][j]));
}
int main() {
int i,j,u,v,w,k=1;
while(~scanf("%d",&n)) {
if(!n)break;
for(i=0; i<n; i++) {
for(j=0; j<n; j++)
mmap[i][j]=(double)inf;
mmap[i][i]=0;
}
for(i=0; i<n; i++) {
scanf("%lf%lf",&p[i].x,&p[i].y);
}
for(i=0; i<n; i++) {
for(j=0; j<n; j++) {
mmap[i][j]=dis(p[i],p[j]);
}
}
floyd();
printf("Scenario #%d\n",k++);
printf("Frog Distance = %.3lf\n",mmap[0][1]);
printf("\n");
}
return 0;
}

Frogger
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 25958   Accepted: 8431

Description

Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her
by jumping. 

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

The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone #i. Stone #1 is Freddy's
stone, stone #2 is Fiona's stone, the other n-2 stones are unoccupied. There's a blank line following each test case. Input is terminated by a value of zero (0) for n.

Output

For each test case, print a line saying "Scenario #x" and a line saying "Frog Distance = y" where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line
after each test case, even after the last one.

Sample Input

2
0 0
3 4 3
17 4
19 4
18 5 0

Sample Output

Scenario #1
Frog Distance = 5.000 Scenario #2
Frog Distance = 1.414

POJ培训计划2253_Frogger(最短/floyd)的更多相关文章

  1. POJ 1125 Stockbroker Grapevine(floyd)

    http://poj.org/problem?id=1125 题意 : 就是说想要在股票经纪人中传播谣言,先告诉一个人,然后让他传播给其他所有的经纪人,需要输出的是从谁开始传播需要的时间最短,输出这个 ...

  2. POJ 3216 最小路径覆盖+floyd

    Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6646   Accepted: 178 ...

  3. POJ 3660 Cow Contest (Floyd)

    http://poj.org/problem?id=3660 题目大意:n头牛两两比赛经过m场比赛后能判断名次的有几头可转 化为路径问题,用Floyd将能够到达的路径标记为1,如果一个点能 够到达剩余 ...

  4. poj 2253 Frogger(最短路 floyd)

    题目:http://poj.org/problem?id=2253 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路的元 ...

  5. POJ 1502 MPI Maelstrom( Spfa, Floyd, Dijkstra)

    题目大意: 给你 1到n ,  n个计算机进行数据传输, 问从1为起点传输到所有点的最短时间是多少, 其实就是算 1 到所有点的时间中最长的那个点. 然后是数据 给你一个n 代表有n个点, 然后给你一 ...

  6. POJ 2391 Ombrophobic Bovines (Floyd + Dinic +二分)

    Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11651   Accepted: 2 ...

  7. POJ 1125 Stockbroker Grapevine【floyd简单应用】

    链接: http://poj.org/problem?id=1125 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

  8. POJ 3660—— Cow Contest——————【Floyd传递闭包】

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

  9. POJ 3660 Cow Contest 传递闭包+Floyd

    原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

随机推荐

  1. android百度地图打包混淆 用不了No such file or directory (2) com.baidu.mapapi.BMapManager.init(Unknown Source)

    调用了百度地图地图开发包是baidumapapi_v2_1_1.jar,定位SDK版本是locSDK_3.3.jar 调试的时候能运行!可是打包签名后就运行不了! baidu  google 了好久! ...

  2. Gap 锁

    14.3.1 InnoDB Locking InnoDB 锁 本章节描述InnoDB 使用的锁类型: Shared and Exclusive Locks Intention Locks Record ...

  3. boost 的函数式编程库 Phoenix入门学习

    这篇文章是我学习boost phoenix的总结. 序言 Phoenix是一个C++的函数式编程(function programming)库.Phoenix的函数式编程是构建在函数对象上的.因此,了 ...

  4. 一个发送邮件的C++库–jwsmtp

    接收邮件的,暂时没搞定,不过在SF上找到了这个发送邮件的库文件.它提供了一个比较完整的类,可以简单的调用发送邮件.下面是作者提供的一个例子,不过由于连SMTP发邮件需要密码,所以代码我改了一下.// ...

  5. 降低成本是永恒的追求(xamarin)

    减少为主线的成本始终是一个社会经济发展.经济活动似乎很.商业模式的出现相关.我记得早起写Web程序,真正的企业并不多忙.大部分时间处理与浏览器的问题之间的差异所带来. 有些型号也做了屏蔽这样的差别,有 ...

  6. stm32f103 TIM1初始化--定时器应用

    //TIM1 分频 #define TIM1_DIV1 (1-1) #define TIM1_DIV2 (2-1) #define TIM1_DIV4 (4-1) #define TIM1_DIV8 ...

  7. Java Web----Java Web的数据库操作(二)

    Java Web的数据库操作 三.JDBC操作数据库 上一篇介绍了JDBC API,之后就可以通过API来操作数据库,实现对数据库的CRUD操作了. http://blog.csdn.net/zhai ...

  8. SCU 3132(博弈)

    传送门:windy和水星 -- 水星游戏 1 题意:在一张由 n*m 的格子组成的棋盘上放着 k 个骑士每个骑士的位置为(xi,yi),表示第xi行,第yi列骑士如果当前位置为(x,y),一步可以走的 ...

  9. cocos2d-js-v3.0-rc0 下 pomelo-cocos2d-jsb native web 配置

    一.基本步骤 注意:pomelo-cocos2d-jsb 没实用 https://github.com/NetEase/pomelo-cocos2d-jsb,原因这个不是最新版,另外,componen ...

  10. IDEA系统提示中文乱码问题及解决

    近期要切换到IDEA开发, 在输出界面发现打印小方格, 或者乱码, 是由于字体不支持中文, 选择一个支持中文的就正常了.(由于IDEA在国内下载错误信息会用中文显示. 而之前Eclipse错误都是英文 ...