#P3181. [HAOI2016] 找相同字符

[HAOI2016] 找相同字符

Description

Given two strings, count the number of ways to take one substring from each string such that the two substrings are equal. Two ways are different if and only if at least one of the substrings has a different position.

Input Format

Two lines: two strings s1,s2s_1, s_2, of lengths n1,n2n_1, n_2, respectively.

Output Format

Output a single integer representing the answer.

aabb
bbaa
10

Hint

1n1,n22×1051 \le n_1, n_2 \le 2 \times 10^5, and the strings contain only lowercase letters.

Translated by ChatGPT 5