文件名称:dist
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:757.63kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
问题描述:
给定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_/Debug/dist_.ilk
dist_/Debug/dist_.obj
dist_/Debug/dist_.pch
dist_/Debug/dist_.pdb
dist_/Debug/vc60.idb
dist_/Debug/vc60.pdb
dist_/dist.pdf
dist_/dist.ppt
dist_/dist_.cpp
dist_/dist_.dsp
dist_/dist_.dsw
dist_/dist_.ncb
dist_/dist_.opt
dist_/dist_.plg
dist_/ReadMe.txt
dist_/StdAfx.cpp
dist_/StdAfx.h
dist_/Debug
dist_
dist_/Debug/dist_.ilk
dist_/Debug/dist_.obj
dist_/Debug/dist_.pch
dist_/Debug/dist_.pdb
dist_/Debug/vc60.idb
dist_/Debug/vc60.pdb
dist_/dist.pdf
dist_/dist.ppt
dist_/dist_.cpp
dist_/dist_.dsp
dist_/dist_.dsw
dist_/dist_.ncb
dist_/dist_.opt
dist_/dist_.plg
dist_/ReadMe.txt
dist_/StdAfx.cpp
dist_/StdAfx.h
dist_/Debug
dist_
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.