POJ 2253
- #include<iostream>
- #include<stdio.h>
- #include<math.h>
- #include<iomanip>
- #define MAXN 250
- #define inf 1000000000
- typedef double elem_t;
- using namespace std;
- double _m[MAXN][MAXN];
- struct point
- {
- double a;
- double b;
- };
- elem_t prim(int n,elem_t mat[][MAXN],int* pre);
- point p[];
- int pre[];
- int main()
- {
- //freopen("acm.acm","r",stdin);
- int num;
- int max = ;
- int i;
- int time = ;
- int j;
- int value;
- while(cin>>num)
- {
- if(!num)
- break;
- cin>>p[].a;
- cin>>p[].b;
- cin>>p[].a;
- cin>>p[].b;
- memset(_m,,sizeof(_m));
- for(i = ; i < num; ++ i)
- {
- cin>>p[i].a;
- cin>>p[i].b;
- }
- for(i = ; i < num; ++ i)
- {
- for(j = i; j < num; ++ j)
- {
- _m[i][j] = (p[i].a - p[j].a)*(p[i].a - p[j].a) + (p[i].b - p[j].b)*(p[i].b - p[j].b);
- _m[j][i] = _m[i][j];
- }
- }
- prim(num,_m,pre);
- i = ;
- while()
- {
- if(_m[i][pre[i]] > max)
- {
- max = _m[i][pre[i]];
- }
- if(pre[i] == )
- break;
- i = pre[i];
- }
- cout<<"Scenario #"<<++ time<<endl
- <<"Frog Distance = "
- <<setiosflags(ios::fixed)<<setprecision()<<sqrt(long double (max))<<endl
- <<endl;
- max = ;
- }
- }
- elem_t prim(int n,elem_t mat[][MAXN],int* pre){
- elem_t min[MAXN],ret=;
- int v[MAXN],i,j,k;
- for (i=;i<n;i++)
- min[i]=inf,v[i]=,pre[i]=-;
- for (min[j=]=;j<n;j++){
- for (k=-,i=;i<n;i++)
- if (!v[i]&&(k==-||min[i]<min[k]))
- k=i;
- for (v[k]=,ret+=min[k],i=;i<n;i++)
- if (!v[i]&&mat[k][i]<min[i])
- min[i]=mat[pre[i]=k][i];
- }
- return ret;
- }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com
POJ 2253的更多相关文章
- 最短路(Floyd_Warshall) POJ 2253 Frogger
题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...
- poj 2253 Frogger (最长路中的最短路)
链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...
- 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、最长边最小化】
Frogger Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- 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),Dijkstra松弛条件的变形
题目链接:http://poj.org/problem?id=2253 题意: 给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通 ...
- POJ 2253 Frogger 最短路 难度:0
http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath&g ...
- POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- POJ 2253 Frogger(floyd)
http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...
随机推荐
- 2018.10.21 codeforces1071B. Minimum path(dp+贪心+bfs)
传送门 唉考试的时候写错了两个细节调了一个多小时根本没调出来. 下来又调了半个小时才过. 其实很简单. 我们先dpdpdp出最开始最多多少个连续的aaa. 然后对于没法继续连续下去的用贪心+bfsbf ...
- 2018.09.21 codeforces1051D. Bicolorings(线性dp)
传送门 sb线性DP. f[i][j][0/1/2/3]f[i][j][0/1/2/3]f[i][j][0/1/2/3]表示前i列j个连通块且第i列状态为00/01/10/11时的方案总数. 这个显然 ...
- 马婕 2014MBA专硕考试 报刊选读 4 朝鲜战争会爆发吗?(转)
http://blog.sina.com.cn/s/blog_3e66af4601016ela.html War unlikely, but Koreans still on cliff edge 战 ...
- Django入门与实践-第25章:Markdown 支持(完结)
http://127.0.0.1:8000/boards/1/topics/102/reply/ 让我们在文本区域添加 Markdown 支持来改善用户体验. 你会看到要实现这个功能非常简单. 首先, ...
- TabHost实现通话记录界面
//MainActivity.java public class MainActivity extends TabActivity { @Override public ...
- PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏
1048. Find Coins (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves t ...
- [Ubuntu Version] 如何在terminal 查看当前 ubuntu的版本号
命令: locate locate /etc/*release/etc/lsb-release/etc/os-release 命令: catcat /etc/os-releaseNAME=" ...
- delphi_xe开发ios环境的安装与设置
http://wenku.baidu.com/link?url=NE3xJOZiLppdxCbXJX3W0vyLHv6uA_U8uamjx9NJIIcxnfuC2P9eWx3d6Xwco-ugS8G ...
- mac下能同时安装两个版本的xcode吗
http://www.cocoachina.com/bbs/read.php?tid-288160-page-1.html
- GitHub Android 开源项目汇总 (转)
转自:http://blog.csdn.net/ithomer/article/details/8882236 GitHub 上的开源项目不胜枚举,越来越多的开源项目正在迁移到GitHub平台上.基于 ...