EditingOperation

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3540
64-bit integer IO format: %I64d      Java class name: Main

Description

There are two strings: A and B. We define an editing operation as “Insert a character”, “Delete a character” or “Replace a character”.
So your task is to calculate how many editing operations do we need to make B become the substring of A? If the answer is more than the given limitation, just output -1.

Input

Multiple test cases.
There are 3 lines in each test case:
String A is given in the first line, and the length of A is from 0 to 1000000.
String B is given in the second line, and the length of B is from 0 to 1000.
In the third line, there is an integer LIM. (0<= LIM <=30)

Output

Print the number of editing operations in one line. If the answer is more than LIM, just output -1.

Sample Input

annealing
annual
3

Sample Output

1

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .