Other / Mixed Topics

Answer & solution
Official answer: 34
Step through it (37 steps)
1. Set up the reasoning. Try to embed the entire five-letter A in B first. After choosing q,p,q in order in B, only one trailing r remains, so no length-five common subsequence exists. Then enumerate the distinct strings obtained by deleting one character from A.
2. Derive the result. The longest common subsequence length for qpqrr and pqprqrp is 4. The distinct length 4 common strings are pqrr, qpqr, qprr. The entire 5-letter first string is not a subsequence of the second, so no longer one exists. Therefore x+10y=4+30=34, counting distinct subsequence strings rather than embeddings.
3. Check the interpretation. Deleting the first, second, or third character gives pqrr, qqrr, qprr; deleting either final r gives qpqr. Of these, qqrr is not a subsequence of B, leaving three distinct length-four strings. Repeated embeddings of one string are not counted separately.