F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Necklace

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 686    Accepted Submission(s): 232


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.
 

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.
 

Output
For each test case, output an integer, the least diamonds that has to be removed.
 

Sample Input
1 ababaa aba
 

Sample Output
1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 04:34:02, Gzip enabled