当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2681:Anagrammatic Distance

题目描述
Two words are said to be anagrams of each other if the letters from one word can be rearranged to form the other word. For example, occurs is an anagram of succor; however, dear is not an anagram of dared (because the d appears twice in dared, but only once in dear). The most famous anagram pair (in English) is dog and god.
The anagrammatic distance between any two words is the minimum number of letters which must be removed so that the remaining portions of the two words become anagrams. For example, given the words sleep and leap, we need to remove a minimum of three letters ---two from sleep and one from leap ---before what's left are anagrams of each other (in each case, lep). With words such as dog and cat, where the two have absolutely no letters in common, the anagrammatic distance is an extreme (explicitly 6) since all the letters need to be removed. (Here, a word is always an anagram of itself.)
You must write a program to calculate the anagrammatic distance between any two given words.
输入解释
The first line of the input will contain a positive integer value N (less than 60,000) indicating the number of cases. Each case will consist of two words, possibly empty, each given on a single line (for a total of 2N additional lines).
Although they may have zero length, the words are simple ---the letter are all lowercase and are taken from the usual twenty-six letter English alphabet (abcdefghijklmnopqrstuvwxyz). The longest word is pneumonoultramicroscopicsilicovolcanoconiosis.
输出解释
The output should consist of the case number and the anagrammatic distance, formatted as shown.
输入样例
4
crocus
succor
dares
seared
empty

smell
lemon
输出样例
Case #1:  0 
Case #2:  1 
Case #3:  5  
Case #4:  4  

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2681

最后修改于 2020-10-29T06:39:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536