SalesforceOA #1
String Subsequences
估计中等可在线判题
Count how many times a pattern string of length exactly 3 occurs in the text as a subsequence. Occurrences are distinguished by the triple of kept positions; they need not be contiguous, and repeated letters are still counted by position.
输入格式
The first line is the pattern, and the second line is the text. The pattern has length 3 and the text has length 1..500000; both contain only A..Z.
输出格式
Output the exact integer, without taking a modulus, using a 64-bit integer.
样例 1
输入:
ABC
ABCBABC
输出:
5
样例 2
输入:
AAA
AAAA
输出:
4
样例 3
输入:
ABA
AB
输出:
0
样例说明
The three examples have 5, 4, and 0 choices of positions, respectively.