#abc353e. E - Yet Another Sigma Problem
E - Yet Another Sigma Problem
Score: points
问题陈述
对于字符串 和 ,定义 如下:
- 是 和 的最长公共前缀的长度。
给定由小写英文字母组成的 个字符串 。找出以下表达式的值:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(S_i,S_j)$。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
For strings and , define as follows:
- is the length of the longest common prefix of and .
You are given strings consisting of lowercase English letters. Find the value of the following expression:
$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(S_i,S_j)$.
Constraints
- is a string consisting of lowercase English letters.
- All input numbers are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
ab abc arc
Sample Output 1
4
Thus, the answer is .
Sample Input 2
11
ab bb aaa bba baba babb aaaba aabbb a a b
Sample Output 2
32
相关
在下列比赛中: