-
算法实现题2
算法实现题2-1 输油管道问题
« 问题描述:
某石油公司计划建造一条由东向西的主输油管道。该管道要穿过一个有n 口油井的油
田。从每口油井都要有一条输油管道沿最短路经(或南或北)与主管道相连。如果给定n口油
井的位置,即它们的x 坐标(东西向)和y 坐标(南北向),应如何确定主管道的最优位置,
即使各油井到主管道之间的输油管道长度总和最小的位置?证明可在线性时间内确定主管道
的最优位置。
« 编程任务:
给定n 口油井的位置,编程计算各油井到主管道之间的输油管道最小长度总和。
« 数据输入:
由文件input.txt 提供输入数据。文件的第1 行是油井数n,1£ n£ 10000。接下来n 行是
油井的位置,每行2个整数x和y,-10000£ x,y£ 10000。
« 结果输出:
程序运行结束时,将计算结果输出到文件output.txt 中。文件的第1 行中的数是油井到
主管道之间的输油管道最小长度总和。
输入文件示例 输出文件示例
input.txt output.txt
5
1 2
2 2
1 3
3 -2
3 3
6
- 2022-11-12 20:40:04下载
- 积分:1
-
VC精华文章――api篇《中华电脑书库制作 》
VC精华文章――api篇《中华电脑书库制作 》-VC essence article-- api title "China produced computer room"
- 2023-08-12 06:10:03下载
- 积分:1
-
其一fartboy谁喜欢的女孩
its a fartboy who liks girls
- 2022-04-29 04:28:02下载
- 积分:1
-
他计划使用INI文件确定菜单程序。程序动态…
his program uses an ini file to determine a menu routine. The program dynamically adds menus that run programs and has the ability to pass arguements to those programs if needed. The program can go 5 submenu s deep and can start from no menus to basically an unlimited amount of menus. Have also written in C++ builder but haven t made the Cbuilder one go 5 subs deep yet.-his program uses an ini file to determine a menu routine. The program dynamically adds menus that run programs and has the ability to pass arguements to those programs if needed. The program can go 5 submenu s deep and can start from no menus to basically an unlimited amount of menus. Have also written in C++ builder but haven t made the Cbuilder one go 5 subs deep yet.
- 2022-06-17 04:57:32下载
- 积分:1
-
csharpprimerprograms
csharpprimerprograms
- 2022-07-22 18:11:56下载
- 积分:1
-
zhanyue.....wokao...
斩月函数的应用 我靠 上载个东东这么麻烦啊-zhanyue.....wokao...
- 2023-07-05 20:25:03下载
- 积分:1
-
机房管理信息系统 机房管理信息系统
机房管理信息系统 机房管理信息系统 -co dsfsadfasdfsafdasfdsafd
- 2022-01-25 17:49:45下载
- 积分:1
-
这是一个用VB开发的在Windows中读取BIOS的内容…
这是一个用VB开发的在Windows下读取Bios内容的软件-This is a development with Visual Basic in Windows to read the contents of Bios software
- 2022-11-07 03:00:03下载
- 积分:1
-
类似金山词霸的ListCtrl控件的完整源代码,推荐啊
类似金山词霸的ListCtrl控件的完整源代码,推荐啊-similar free email ListCtrl control of the integrity of the source code, recommended ah
- 2022-10-16 03:40:03下载
- 积分:1
-
ConvertNumber,本程序用以对数字进行进制转换。十分实用的小程序。...
ConvertNumber,本程序用以对数字进行进制转换。十分实用的小程序。-ConvertNumber, the procedures used to convert hexadecimal numbers. Very useful applet.
- 2022-01-27 09:40:41下载
- 积分:1