305796: CF1090J. Two Prefixes
Memory Limit:512 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Two Prefixes
题意翻译
给定两个字符串s、t,求s的非空前缀后接上t的非空前缀形成的本质不同字符串种类数题目描述
Misha didn't do his math homework for today's lesson once again. As a punishment, his teacher Dr. Andrew decided to give him a hard, but very useless task. Dr. Andrew has written two strings $ s $ and $ t $ of lowercase English letters at the blackboard. He reminded Misha that prefix of a string is a string formed by removing several (possibly none) of its last characters, and a concatenation of two strings is a string formed by appending the second string to the right of the first string. The teacher asked Misha to write down on the blackboard all strings that are the concatenations of some non-empty prefix of $ s $ and some non-empty prefix of $ t $ . When Misha did it, Dr. Andrew asked him how many distinct strings are there. Misha spent almost the entire lesson doing that and completed the task. Now he asks you to write a program that would do this task automatically.输入输出格式
输入格式
The first line contains the string $ s $ consisting of lowercase English letters. The second line contains the string $ t $ consisting of lowercase English letters. The lengths of both string do not exceed $ 10^{5} $ .
输出格式
Output a single integer — the number of distinct strings that are concatenations of some non-empty prefix of $ s $ with some non-empty prefix of $ t $ .
输入输出样例
输入样例 #1
aba
aa
输出样例 #1
5
输入样例 #2
aaaaa
aaaa
输出样例 #2
8