-
算法实现题2
算法实现题2-3 邮局选址问题
« 问题描述:
在一个按照东西和南北方向划分成规整街区的城市里,n个居民点散乱地分布在不同的
街区中。用x 坐标表示东西向,用y坐标表示南北向。各居民点的位置可以由坐标(x,y)表示。
街区中任意2 点(x1,y1)和(x2,y2)之间的距离可以用数值|x1-x2|+|y1-y2|度量。
居民们希望在城市中选择建立邮局的最佳位置,使n个居民点到邮局的距离总和最小。
« 编程任务:
给定n 个居民点的位置,编程计算n 个居民点到邮局的距离总和的最小值。
« 数据输入:
由文件input.txt 提供输入数据。文件的第1 行是居民点数n,1£ n£ 10000。接下来n 行
是居民点的位置,每行2 个整数x 和y,-10000£ x,y£ 10000。
« 结果输出:
程序运行结束时,将计算结果输出到文件output.txt 中。文件的第1 行中的数是n 个居
民点到邮局的距离总和的最小值。
输入文件示例 输出文件示例
input.txt output.txt
5
1 2
2 2
1 3
3 -2
3 3
10
- 2022-08-26 13:24:17下载
- 积分:1
-
FEM book:The_Finite_Element_Method by Thomas J. R. Hughes
Thomas J. R. Hughes 著作-FEM book:The_Finite_Element_Method by Thomas J. R. Hughes
- 2022-10-31 18:40:03下载
- 积分:1
-
The system will automatically delete the directory, so please do not file on thi...
系统会自动删除目录,所以请不要将文件放在这两个目录下请认真阅读您的文件包然后写出其具体功能-The system will automatically delete the directory, so please do not file on this directory both Please read them carefully package your specific function and then write
- 2023-03-04 17:05:04下载
- 积分:1
-
《面向对象程序设计》练习10_11的源代码
《面向对象程序设计》练习10_11的源代码- Object-oriented programming, the source code of practice 10_11
- 2022-03-29 05:47:46下载
- 积分:1
-
本文件包括的xml的开发应用标准,1998年由w3c制定
本文件包括的xml的开发应用标准,1998年由w3c制定-this document include the development and application of xml standards, in 1998 developed by the w3c
- 2023-04-05 14:00:03下载
- 积分:1
-
实现注册表项的导入与导出
实现注册表项的导入与导出-achieve registry import and export
- 2022-10-26 12:55:03下载
- 积分:1
-
一个Flex
一个基于flex的图片效果..非不错的哦..大家可以下载下来-A flex-based images of non-good effect .. oh .. you can download it
- 2022-02-14 18:22:26下载
- 积分:1
-
use com to read/write excel files
windows下通过com服务读写excel的例子-use com to read/write excel files
- 2022-09-22 00:30:02下载
- 积分:1
-
C achieved a simple drawing program. Including line drawing, Circle, Rectangle,...
用C++实现的一个简单的画图程序。包括画线,画圆,画矩形等。-C achieved a simple drawing program. Including line drawing, Circle, Rectangle, and other paintings.
- 2022-02-04 13:36:37下载
- 积分:1
-
One names depth of a tree the maximum number of "descents" which can be carried...
One names depth of a tree the maximum number of "descents" which can be carried out starting from the root. For example, the third binary tree of figure 1 has a depth of 3.According to this reasoning, a tree having one or no node is of depth 0.
- 2022-12-27 07:35:03下载
- 积分:1