文件名称:From-the-string
介绍说明--下载内容来自于网络,使用问题请自行百度
问题描述:
设有字符串X,我们称在X的头尾及中间插入任意多个空格后构成的新字符串为X的扩展串,如字符串X为“abcbcd”,则字符串“abcb□cd”,“□a□bcbcd□”和“abcb□cd□”都是X的扩展串,这里“□”代表空格字符。 如果A1是字符串A的扩展串,B1是字符串B的扩展串,A1与B1具有相同的长度,那么我们定义字符串A1与B1的距离为相应位置上的字符的距离总和,而两个非空格字符的距离定义为它们的ASCII码的差的绝对值,而空格字符与其它任意字符之间的距离为已知的定值K,空格字符与空格字符的距离为O。在字符串A、B的所有扩展串中,必定存在两个等长的扩展串A1、B1,使得A1与B1之间的距离达到最小,我们将这一距离定义为字符串A、B的距离。 请你写一个程序,求出字符串A、B的距离。
输入:
有多组数据,每一组数据第一行为字符串A,第二行为字符串B,A、B均由小写字母组成且长度均不超过2000,第三行为一个整数K,1≤K≤100,表示空格与其它字符的距离。
输出:
每组数据一行包含一个整数,表示要求的字符串A、B的距离。-Problem Descr iption :
With a string of X, we call the new string is inserted after any number of spaces in the middle of the head and tail and composed for the X X extension string , such as string X is "abcbcd", the string "abcb □ cd", "□ a □ bcbcd □" and "abcb □ cd □" are X extensions string here "□" on behalf of a space character. If A1 is the extended string string A , B1 B is an extension of substrings , A1 and B1 have the same length , then we define a string from the sum of the distances A1 and B1 on the corresponding character position , and the two from the definition of non- space character is absolute difference of their ASCII codes, and the distance to any other character with a space character between a known K, from the space character and the space character value is O. String A, B in all the extended string , and so there must be two extended string length A1, B1, so that the distance between A1 and B1 to a minimum , this distance will be defined as a string A, the
设有字符串X,我们称在X的头尾及中间插入任意多个空格后构成的新字符串为X的扩展串,如字符串X为“abcbcd”,则字符串“abcb□cd”,“□a□bcbcd□”和“abcb□cd□”都是X的扩展串,这里“□”代表空格字符。 如果A1是字符串A的扩展串,B1是字符串B的扩展串,A1与B1具有相同的长度,那么我们定义字符串A1与B1的距离为相应位置上的字符的距离总和,而两个非空格字符的距离定义为它们的ASCII码的差的绝对值,而空格字符与其它任意字符之间的距离为已知的定值K,空格字符与空格字符的距离为O。在字符串A、B的所有扩展串中,必定存在两个等长的扩展串A1、B1,使得A1与B1之间的距离达到最小,我们将这一距离定义为字符串A、B的距离。 请你写一个程序,求出字符串A、B的距离。
输入:
有多组数据,每一组数据第一行为字符串A,第二行为字符串B,A、B均由小写字母组成且长度均不超过2000,第三行为一个整数K,1≤K≤100,表示空格与其它字符的距离。
输出:
每组数据一行包含一个整数,表示要求的字符串A、B的距离。-Problem Descr iption :
With a string of X, we call the new string is inserted after any number of spaces in the middle of the head and tail and composed for the X X extension string , such as string X is "abcbcd", the string "abcb □ cd", "□ a □ bcbcd □" and "abcb □ cd □" are X extensions string here "□" on behalf of a space character. If A1 is the extended string string A , B1 B is an extension of substrings , A1 and B1 have the same length , then we define a string from the sum of the distances A1 and B1 on the corresponding character position , and the two from the definition of non- space character is absolute difference of their ASCII codes, and the distance to any other character with a space character between a known K, from the space character and the space character value is O. String A, B in all the extended string , and so there must be two extended string length A1, B1, so that the distance between A1 and B1 to a minimum , this distance will be defined as a string A, the
(系统自动生成,下载前可以参看下载内容)
下载文件列表
字符串的距离(2).cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.