#abc322b. B - Prefix and Suffix
B - Prefix and Suffix
Score : points
问题描述
你将获得两个由小写英文字母组成的字符串 和 ,其长度分别为 和 。(约束条件保证了 。)
如果 的前 个字符与 相同,则称 是 的 前缀。 如果 的最后 个字符与 相同,则称 是 的 后缀。
- 若 同时是 的前缀和后缀,则输出 ;
- 若 是 的前缀但不是后缀,则输出 ;
- 若 是 的后缀但不是前缀,则输出 ;
- 若 不是 的前缀也不是后缀,则输出 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given two strings and consisting of lowercase English letters. The lengths of and are and , respectively. (The constraints guarantee that .)
is said to be a prefix of when the first characters of coincide .
is said to be a suffix of when the last characters of coincide .
If is both a prefix and a suffix of , print ;
If is a prefix of but not a suffix, print ;
If is a suffix of but not a prefix, print ;
If is neither a prefix nor a suffix of , print .
Constraints
- is a string of length consisting of lowercase English letters.
- is a string of length consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print the answer according to the instructions in the problem statement.
Sample Input 1
3 7
abc
abcdefg
Sample Output 1
1
is a prefix of but not a suffix, so you should print .
Sample Input 2
3 4
abc
aabc
Sample Output 2
2
is a suffix of but not a prefix.
Sample Input 3
3 3
abc
xyz
Sample Output 3
3
is neither a prefix nor a suffix of .
Sample Input 4
3 3
aaa
aaa
Sample Output 4
0
and may coincide, in which case is both a prefix and a suffix of .
update @ 2024/3/10 01:42:03