-
算法实现题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
-
从制定的文件中读入数据,查找重复的号码并随即抽取其中的号码,保存文件...
从制定的文件中读入数据,查找重复的号码并随即抽取其中的号码,保存文件-From the formulation of the document read into the data, repeat the search number and then taking one number, save the file
- 2022-01-26 15:13:01下载
- 积分:1
-
Cui motives box speakers play music, although backward and primitive, but it is...
本程序是崔动机箱内扬声器进行播放音乐,虽然落后并且简陋,但是是我第一个比较满意的程序.(程序中有大部分为借鉴别人)-Cui motives box speakers play music, although backward and primitive, but it is my first one quite satisfied with the procedure. (Procedures are mostly from others)
- 2022-05-21 16:58:42下载
- 积分:1
-
文件管理系统源代码
文件管理系统源代码-document management system source code
- 2022-02-20 10:26:15下载
- 积分:1
-
Visual C++ 6.0项目开发指南
Visual C++ 6.0项目开发指南-Visual C 6.0 project development guidelines
- 2022-03-30 04:46:03下载
- 积分:1
-
UPX the shell, with the source code!
upx的shell,附源代码!-UPX the shell, with the source code!
- 2022-12-12 06:50:03下载
- 积分:1
-
powerbuilder 日期控件
powerbuilder 日期控件-PowerBuilder date Controls
- 2022-08-10 12:39:23下载
- 积分:1
-
gfg
小票打印机驱动程序,适合[Version]Signature="$Windows NT$"Provider=%AUTHOR%LayoutFile=ntprint.infClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}Class=PrinterDriverVer=3/22/2011;; Manufacturer section;[Manufacturer]"POS58"=Generic, NTx86, NTamd64, NTia64;; Model sections. ; ; Each section here corresponds with an entry listed in the; [Manufacturer] section, above. The models will be displayed in the order; that they appear in the INF file.;[Generic]"POS58" = POS58Drv.GPD[Generic.NTx86]"POS58" = POS58Drv.GPD[Generic.NTamd64]"POS58" = POS58Drv.GPD[Generic.NTia64]"POS58" &n
- 2022-03-01 06:55:37下载
- 积分:1
-
定期储蓄管理软件,可存款,取款,挂失,取消挂失,信息输出等功能...
定期储蓄管理软件,可存款,取款,挂失,取消挂失,信息输出等功能-Regular savings management software, may be deposits, withdrawals, report the loss, cancellation of report of loss, the information output functions
- 2022-06-18 08:44:27下载
- 积分:1
-
高校工资管理,功能全面,包括删除、添加修改、
高校工资管理,功能全面,包括删除、添加修改、-salary manage
- 2022-08-21 01:57:47下载
- 积分:1