hdu3489 Necklace
来源:互联网 发布:华为tsm认证通过后数据 编辑:程序博客网 时间:2024/05/17 01:50
http://acm.hdu.edu.cn/showproblem.php?pid=3489
Necklace
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 320 Accepted Submission(s): 137
Problem Description
Henryy gave the princess of the kingdom of Henryy a necklace, which is made by a series of diamonds which are the most valuable among the world.
The necklace can be regarded as a string of diamonds. (Notice that it’s not a loop of them!) In the kingdom, another kind of necklace is very popular, but it is much less precious. If this kind of necklace is a sub-string (not sub-sequence) of the princess’, maybe somebody will use the fake one to replace a part of it, and this is quite dangerous. Thus, Henryy want to remove some of the diamonds off from the necklace to make it safer. This number, of course, should be as small as possible.
The necklace can be regarded as a string of diamonds. (Notice that it’s not a loop of them!) In the kingdom, another kind of necklace is very popular, but it is much less precious. If this kind of necklace is a sub-string (not sub-sequence) of the princess’, maybe somebody will use the fake one to replace a part of it, and this is quite dangerous. Thus, Henryy want to remove some of the diamonds off from the necklace to make it safer. This number, of course, should be as small as possible.
Input
The first line contains an integer T (1 ≤ T ≤ 10) which means T test cases follow:
In each test case:
The first line is a string indicating the princess’ necklace with its length no more than 10000 and made up by characters from ‘a’ to ‘z’.
The second line is the common necklace, with its length no more than 1000 and also made up by characters from ‘a’ to ‘z’.
The two necklaces cannot be reversed. (For example, a necklace “abc” cannot be regarded as “cba”.)
A blank line is followed after each test case.
In each test case:
The first line is a string indicating the princess’ necklace with its length no more than 10000 and made up by characters from ‘a’ to ‘z’.
The second line is the common necklace, with its length no more than 1000 and also made up by characters from ‘a’ to ‘z’.
The two necklaces cannot be reversed. (For example, a necklace “abc” cannot be regarded as “cba”.)
A blank line is followed after each test case.
Output
For each test case, output an integer, the least diamonds that has to be removed.
Sample Input
1ababaaaba
Sample Output
1
Source
2010 ACM-ICPC Multi-University Training Contest(6)——Host by BIT
- hdu3489 Necklace
- necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- J - Necklace
- hdu3091 Necklace
- broken necklace
- THUSC2011 necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- Broken Necklace
- freeman 链码
- 图片
- 接下来我将干嘛
- 遇到的一些Qt函数记录
- Windows消息编程
- hdu3489 Necklace
- 叔本华小记
- 关于EXCEL2007导入DataSet报“外部表不是预期的格式”的解决方法
- Android进阶之Mp3项目(一)
- 袁岳:交朋友的11个小技巧 穆利堂推荐
- android中apidemos中的fingerpaint学习
- 线程的讲解
- Cisco OSPF 外部路由记录的路由选择
- MD5算法