#abc213f. F - Common Prefixes
F - Common Prefixes
Score : points
问题描述
令两个字符串 和 之间的 相似度 为它们最长公共前缀的长度。
例如,字符串 abc
和 axbc
之间的相似度为 ,而字符串 aaa
和 aaaa
之间的相似度为 。
现在给定一个长度为 的字符串 。令 表示从 的第 个字符开始的后缀。对于每个 ,计算并求出 的值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Let the similarity between two strings and be the length of their longest common prefix.
For example, the similarity between abc
and axbc
is , and the similarity between aaa
and aaaa
is .
You are given a string of length . Let be the suffix of beginning with the -th character of . For each , find .
Constraints
- is a string of length consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer for .
Sample Input 1
3
abb
Sample Output 1
3
3
2
is abb
, is bb
, and is b
.
- For : .
- For : .
- For : .
Sample Input 2
11
mississippi
Sample Output 2
11
16
14
12
13
11
9
7
4
3
4
update @ 2024/3/10 09:30:07