logo AlgoBeat OnlineJudge
登录 注册

#216187. [ICPC 2019 NAIPC] Subsequences in Substrings

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given two strings , and . Count the number of substrings of that contain as a subsequence at least once.

Note that a substring and a subsequence both consist of characters from the original string, in order. In a substring, the characters must be contiguous in the original string, but in a subsequence, they are not required to be contiguous. In the string abcde, ace is a subsequence but not a substring.

If is aa and is a, then the answer is 3: [a]a, [aa], and a[a].

输入格式

Each test case will consist of exactly two lines.

The first line will contain string (, ), with no other characters.

The second line will contain string (, , ), with no other characters.

输出格式

Output a single integer, which is the number of substrings of that contain as a subsequence at least once.

样例

样例输入 1

abcdefghijklmnopqrstuvwxyz
a

样例输出 1

26

样例输入 2

abcdefghijklmnopqrstuvwxyz
m

样例输出 2

182

样例输入 3

penpineappleapplepen
ppap

样例输出 3

68