1. #include<iostream>
  2. #include<stdio.h>
  3. #include<math.h>
  4. #include<iomanip>
  5. #define MAXN 250
  6. #define inf 1000000000
  7. typedef double elem_t;
  8.  
  9. using namespace std;
  10.  
  11. double _m[MAXN][MAXN];
  12. struct point
  13. {
  14. double a;
  15. double b;
  16. };
  17. elem_t prim(int n,elem_t mat[][MAXN],int* pre);
  18. point p[];
  19. int pre[];
  20. int main()
  21. {
  22. //freopen("acm.acm","r",stdin);
  23. int num;
  24. int max = ;
  25. int i;
  26. int time = ;
  27. int j;
  28. int value;
  29. while(cin>>num)
  30. {
  31. if(!num)
  32. break;
  33. cin>>p[].a;
  34. cin>>p[].b;
  35. cin>>p[].a;
  36. cin>>p[].b;
  37. memset(_m,,sizeof(_m));
  38. for(i = ; i < num; ++ i)
  39. {
  40. cin>>p[i].a;
  41. cin>>p[i].b;
  42. }
  43. for(i = ; i < num; ++ i)
  44. {
  45. for(j = i; j < num; ++ j)
  46. {
  47. _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);
  48. _m[j][i] = _m[i][j];
  49. }
  50. }
  51. prim(num,_m,pre);
  52. i = ;
  53. while()
  54. {
  55. if(_m[i][pre[i]] > max)
  56. {
  57. max = _m[i][pre[i]];
  58. }
  59. if(pre[i] == )
  60. break;
  61. i = pre[i];
  62. }
  63. cout<<"Scenario #"<<++ time<<endl
  64. <<"Frog Distance = "
  65. <<setiosflags(ios::fixed)<<setprecision()<<sqrt(long double (max))<<endl
  66. <<endl;
  67. max = ;
  68. }
  69.  
  70. }
  71.  
  72. elem_t prim(int n,elem_t mat[][MAXN],int* pre){
  73. elem_t min[MAXN],ret=;
  74. int v[MAXN],i,j,k;
  75. for (i=;i<n;i++)
  76. min[i]=inf,v[i]=,pre[i]=-;
  77. for (min[j=]=;j<n;j++){
  78. for (k=-,i=;i<n;i++)
  79. if (!v[i]&&(k==-||min[i]<min[k]))
  80. k=i;
  81. for (v[k]=,ret+=min[k],i=;i<n;i++)
  82. if (!v[i]&&mat[k][i]<min[i])
  83. min[i]=mat[pre[i]=k][i];
  84. }
  85. return ret;
  86. }

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 2253的更多相关文章

  1. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

  2. poj 2253 Frogger (最长路中的最短路)

    链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...

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

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

  4. POJ. 2253 Frogger (Dijkstra )

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

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

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

  6. POJ 2253 Frogger(dijkstra 最短路

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

  7. Poj(2253),Dijkstra松弛条件的变形

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

  8. POJ 2253 Frogger 最短路 难度:0

    http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath&g ...

  9. POJ 2253 Frogger

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

  10. POJ 2253 Frogger(floyd)

    http://poj.org/problem?id=2253 题意 : 题目是说,有这样一只青蛙Freddy,他在一块石头上,他呢注意到青蛙Fiona在另一块石头上,想去拜访,但是两块石头太远了,所以 ...

随机推荐

  1. 2018.10.21 codeforces1071B. Minimum path(dp+贪心+bfs)

    传送门 唉考试的时候写错了两个细节调了一个多小时根本没调出来. 下来又调了半个小时才过. 其实很简单. 我们先dpdpdp出最开始最多多少个连续的aaa. 然后对于没法继续连续下去的用贪心+bfsbf ...

  2. 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时的方案总数. 这个显然 ...

  3. 马婕 2014MBA专硕考试 报刊选读 4 朝鲜战争会爆发吗?(转)

    http://blog.sina.com.cn/s/blog_3e66af4601016ela.html War unlikely, but Koreans still on cliff edge 战 ...

  4. Django入门与实践-第25章:Markdown 支持(完结)

    http://127.0.0.1:8000/boards/1/topics/102/reply/ 让我们在文本区域添加 Markdown 支持来改善用户体验. 你会看到要实现这个功能非常简单. 首先, ...

  5. TabHost实现通话记录界面

    //MainActivity.java   public class MainActivity extends TabActivity   {       @Override       public ...

  6. 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 ...

  7. [Ubuntu Version] 如何在terminal 查看当前 ubuntu的版本号

    命令: locate locate /etc/*release/etc/lsb-release/etc/os-release 命令: catcat /etc/os-releaseNAME=" ...

  8. delphi_xe开发ios环境的安装与设置

     http://wenku.baidu.com/link?url=NE3xJOZiLppdxCbXJX3W0vyLHv6uA_U8uamjx9NJIIcxnfuC2P9eWx3d6Xwco-ugS8G ...

  9. mac下能同时安装两个版本的xcode吗

    http://www.cocoachina.com/bbs/read.php?tid-288160-page-1.html

  10. GitHub Android 开源项目汇总 (转)

    转自:http://blog.csdn.net/ithomer/article/details/8882236 GitHub 上的开源项目不胜枚举,越来越多的开源项目正在迁移到GitHub平台上.基于 ...