spoj#SUBS. String it out
String it out
Let A and B be two strings made up of alphabets such that A = A[1-n], B = B[1-m]. We say B is a subsequence of A if there exists a sequence of indices i1 < i2 <..<im</i</b> of A such that A[ik] = B[k].</p>
Given B[1-m], a string of characters from some alphabets, B^i is defined as string with the characters of B each repeating i times. For example, (abbacc)^3 = aaabbbbbbaaacccccc.
Also, B^0 is the empty string.
Given strings X, Y made up of characters from 'a' - 'z' find the maximum value of M such that X^M is a subsequence of Y.
The output must contain t lines, each line corresponding to a test case.
The value on the kth line should be the value of M for the kth pair of X and Y.
Input:
Output:
Input
Output
Example
3
abc
aabbcc
abc
bbccc
abcdef
abc
2
0
0