Similarity
题号:NC15857
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bob has two strings a and b, he wants to calculate the similarity of them. The similarity is defined by the sum of the number of times in string a for each substring in string b.

输入描述:

The first line is the string a.
The second line is the string b.
All strings consist of only lowercase English letters.
The length of string a and the length of string b will not exceed 500000.

输出描述:

Output the similarity of two strings.
示例1

输入

复制
abb
bba

输出

复制
6

说明

For the substring “b”,it appears 2 times in string a.
For the substring “bb”,it appears 1 time in string a.
For the substring “bba”,it appears 0 time in string a.
For the substring “b”,it appears 2 times in string a.
For the substring “ba”,it appears 0 time in string a.
For the substring “a”,it appears 1 time in string a.
So, the similarity is 2+1+0+2+0+1=6.