#P9543. [湖北省选模拟 2023] 日记 / diary
[湖北省选模拟 2023] 日记 / diary
Problem Description
Little M decides to start writing a diary, but she does not want to spend too much time thinking about what to write. So she finds a string of length . She will choose any prefix of , and any suffix of , then concatenate them in order to get the string as the diary content. Here, the empty string is also considered a prefix and a suffix of , so and each have choices.
Of course, many strings formed this way are meaningless. More specifically, Little M treats a known string of length as important information. Any string that contains this important information as a substring is meaningful; otherwise it is meaningless.
Please compute how many essentially different meaningful strings Little M can write in total. “Essentially different” means that for some meaningful string , even if it can be obtained by multiple ways of choosing the prefix and suffix, it should only be counted once.
Input Format
The input has two lines.
The first line contains a string .
The second line contains a string .
Output Format
One line with one integer, the required answer.
aab
ab
7
mikageandspica
spica
140
见选手目录下的 diary/diary3.in 与 diary/diary3.ans。
见选手目录下的 diary/diary3.in 与 diary/diary3.ans。
见选手目录下的 diary/diary4.in 与 diary/diary4.ans。
见选手目录下的 diary/diary4.in 与 diary/diary4.ans。
见选手目录下的 diary/diary5.in 与 diary/diary5.ans。
见选手目录下的 diary/diary5.in 与 diary/diary5.ans。
Hint
Explanation of Sample 1
For the first sample, all meaningful strings that can be formed are ab, aab, aaab, aaaab, aabaab, aabab, aabb, a total of .
Subtasks
For all testdata, it is guaranteed that , . The input strings and contain only lowercase English letters. Here and denote the lengths of strings and , respectively.

- A set of hack testdata was added on 2023.8.21.
Translated by ChatGPT 5