文件名称:dist
- 所属分类:
- Windows编程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 758kb
- 下载次数:
- 0次
- 提 供 者:
- skya****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
问题描述:
给定m个整数组成的向量A, , ,和另一个由n个整数1 2 , , , m a a L a i a ≤m 1≤ i ≤m
组成的向量B, , 。向量A和B之间的距离dist定义为: 1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n
( ) { }。1 ,1
, min i m j n i j
dist A B a b
≤ ≤ ≤ ≤
= −
向量距离问题要求给定向量A和B的距离。
例如,当m=5,n=5,相应向量A为:(-5,3,-5,2,4),向量B为:(-2,-3,-2,-3,-1)
时,dist(A, B) = 2。
编程任务:
对于给定的m 个整数组成的向量A, , ,和另一个由n 1 2 , , , m a a L a i a ≤m 1≤ i ≤m
个整数组成的向量B, , ,试设计一个O(m + n)时间算法,计1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n
算给定向量A和B的距离。
数据输入:
由文件input.txt提供输入数据。文件的第1行有2个正整数m和n。第2行是整数向量A:
。第3行是整数向量B: 。1 2 , , , m a a L a 1 2 , , , n b b L b
结果输出:
程序运行结束时,将计算出的向量A和B的距离输出到output.txt中。
输入示例输出示例
input.txt output.txt
5 5
-5 3 -5 2 4
-2 -3 -2 -3 -1
2-Problem descr iption:
A given integer m, composed of a vector A,,, and another by the n integers 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m
Vector composed of B,,. Vector between A and B is defined as dist from: 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n
() (). 1, 1
, Min i m j n i j
dist A B a b
≤ ≤ ≤ ≤
=--
Vector directed away from the issue of the volume of requests to the distance between A and B.
For example, when m = 5, n = 5, corresponding to vector A: (-5,3,-5,2,4), vector B is: (-2,-3,-2,-3,-1)
When, dist (A, B) = 2.
Programming tasks:
For a given integer m, composed of a vector A,,, and another by the n 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m
Integral component of the vector B,,, try to design a O (m+ n) time algorithm, namely 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n
Directional traffic count to the distance between A and B.
Data entry:
Provided by the input data file input.txt. Line 1 of the document are two positive integers m and n. Line 2 is an integer vector A:
. Line 3 is an integer vector
给定m个整数组成的向量A, , ,和另一个由n个整数1 2 , , , m a a L a i a ≤m 1≤ i ≤m
组成的向量B, , 。向量A和B之间的距离dist定义为: 1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n
( ) { }。1 ,1
, min i m j n i j
dist A B a b
≤ ≤ ≤ ≤
= −
向量距离问题要求给定向量A和B的距离。
例如,当m=5,n=5,相应向量A为:(-5,3,-5,2,4),向量B为:(-2,-3,-2,-3,-1)
时,dist(A, B) = 2。
编程任务:
对于给定的m 个整数组成的向量A, , ,和另一个由n 1 2 , , , m a a L a i a ≤m 1≤ i ≤m
个整数组成的向量B, , ,试设计一个O(m + n)时间算法,计1 2 , , , n b b L b i b ≤ n 1≤ i ≤ n
算给定向量A和B的距离。
数据输入:
由文件input.txt提供输入数据。文件的第1行有2个正整数m和n。第2行是整数向量A:
。第3行是整数向量B: 。1 2 , , , m a a L a 1 2 , , , n b b L b
结果输出:
程序运行结束时,将计算出的向量A和B的距离输出到output.txt中。
输入示例输出示例
input.txt output.txt
5 5
-5 3 -5 2 4
-2 -3 -2 -3 -1
2-Problem descr iption:
A given integer m, composed of a vector A,,, and another by the n integers 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m
Vector composed of B,,. Vector between A and B is defined as dist from: 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n
() (). 1, 1
, Min i m j n i j
dist A B a b
≤ ≤ ≤ ≤
=--
Vector directed away from the issue of the volume of requests to the distance between A and B.
For example, when m = 5, n = 5, corresponding to vector A: (-5,3,-5,2,4), vector B is: (-2,-3,-2,-3,-1)
When, dist (A, B) = 2.
Programming tasks:
For a given integer m, composed of a vector A,,, and another by the n 1 2,,, maa L aia ≤ m 1 ≤ i ≤ m
Integral component of the vector B,,, try to design a O (m+ n) time algorithm, namely 1 2,,, nbb L bib ≤ n 1 ≤ i ≤ n
Directional traffic count to the distance between A and B.
Data entry:
Provided by the input data file input.txt. Line 1 of the document are two positive integers m and n. Line 2 is an integer vector A:
. Line 3 is an integer vector
(系统自动生成,下载前可以参看下载内容)
下载文件列表
dist_
.....\Debug
.....\.....\dist_.exe
.....\.....\dist_.ilk
.....\.....\dist_.obj
.....\.....\dist_.pch
.....\.....\dist_.pdb
.....\.....\vc60.idb
.....\.....\vc60.pdb
.....\dist.pdf
.....\dist.ppt
.....\dist_.cpp
.....\dist_.dsp
.....\dist_.dsw
.....\dist_.ncb
.....\dist_.opt
.....\dist_.plg
.....\ReadMe.txt
.....\StdAfx.cpp
.....\StdAfx.h
.....\Debug
.....\.....\dist_.exe
.....\.....\dist_.ilk
.....\.....\dist_.obj
.....\.....\dist_.pch
.....\.....\dist_.pdb
.....\.....\vc60.idb
.....\.....\vc60.pdb
.....\dist.pdf
.....\dist.ppt
.....\dist_.cpp
.....\dist_.dsp
.....\dist_.dsw
.....\dist_.ncb
.....\dist_.opt
.....\dist_.plg
.....\ReadMe.txt
.....\StdAfx.cpp
.....\StdAfx.h