博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ2349 Arctic Network(Prim)
阅读量:7093 次
发布时间:2019-06-28

本文共 2343 字,大约阅读时间需要 7 分钟。

Arctic Network
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 16968   Accepted: 5412

Description

The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver and some outposts will in addition have a satellite channel.
Any two outposts with a satellite channel can communicate via the satellite, regardless of their location. Otherwise, two outposts can communicate by radio only if the distance between them does not exceed D, which depends of the power of the transceivers. Higher power yields higher D but costs more. Due to purchasing and maintenance considerations, the transceivers at the outposts must be identical; that is, the value of D is the same for every pair of outposts.
Your job is to determine the minimum D required for the transceivers. There must be at least one communication path (direct or indirect) between every pair of outposts.

Input

The first line of input contains N, the number of test cases. The first line of each test case contains 1 <= S <= 100, the number of satellite channels, and S < P <= 500, the number of outposts. P lines follow, giving the (x,y) coordinates of each outpost in km (coordinates are integers between 0 and 10,000).

Output

For each case, output should consist of a single line giving the minimum D required to connect the network. Output should be specified to 2 decimal points.

Sample Input

12 40 1000 3000 600150 750

Sample Output

212.13

Source

【题意】有S颗卫星和P个哨所,有卫星的两个哨所之间可以任意通信;否则,一个哨所只能和距离它小于等于D的哨所通信。给出卫星的数量和P个哨所的坐标,求D的最小值。
【分析】为了练练Prim。可以先用Prim把边建好,存起来,然后把选择的边从小到大排个序,第(n-p-1)个数就是答案。
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define mod 1000000007#define inf 0x3f3f3f3f#define pi acos(-1.0)using namespace std;typedef long long ll;const int N=2005;const int M=15005;double edg[N][N];double lowcost[N];//记录未加入树集合的i离树集合中元素最小的距离int n,m,t,v;double d[N];bool cmp(double a,double b){return a
View Code

转载于:https://www.cnblogs.com/jianrenfang/p/5730404.html

你可能感兴趣的文章
updatepanel的用法之triggers
查看>>
iOS6、7、8、9新特性汇总和适配说明
查看>>
php语法技巧
查看>>
Linux学习---linux的svn的配置与安装
查看>>
Override Inline Styles with CSS
查看>>
Jsp内置对象
查看>>
一个爬虫
查看>>
软件测试第二次作业
查看>>
【译】Master-Worker模式
查看>>
针对OAuth2的CSRF攻击
查看>>
Python基础学习笔记(四:条件判断与缩进)
查看>>
OID,主键生成策略,PO VO DTO,get和load区别,脏检查,快照,java对象的三种状态
查看>>
Objective-C语言分类与协议
查看>>
洛谷P1983 车站分级
查看>>
mongodb
查看>>
统计难题
查看>>
Discrete Function(简单数学题)
查看>>
如何判断某版本的.NET Framework是否安装
查看>>
搭建app自动化测试环境(一)
查看>>
IE加载项
查看>>