Cutting Flower Cloth Strips


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
C++, Python

String Cutting Problem

Given a cloth strip with some patterns on it (the main strip), and a smaller decorative strip with its own patterns, the task is to calculate the maximum number of non-overlapping copies of the decorative strip that can be cut out from the main strip.

Input Format
The input contains multiple test cases. Input stops when a line consisting of a single # is encountered.

Each test case is one line containing two strings separated by a space:

  • The first string is the main cloth strip.
  • The second string is the decorative strip.

Both strings consist of printable ASCII characters (excluding space), and each string's length ≤ 1000.

Important: # is only treated as the termination signal if it appears as the sole character in a line. If a string starts with #, it is part of the normal input.

Output Format
For each test case, output one integer — the maximum number of non-overlapping occurrences of the decorative strip that can be found in the main strip.

Data Range
String length ≤ 1000 for all inputs.

Sample Input

abcde a3
aaaaaa aa
#

Sample Output

0
3

Comments

There are no comments at the moment.