#abc268b. B - Prefix?
B - Prefix?
Score : points
问题描述
给定两个由小写英文字母组成的字符串 和 。判断 是否为 的前缀。
何为前缀?对于长度为 的字符串 ,其前缀是一个字符串,表示为 的前 个字符 ,其中 是一个整数,满足 。例如,当 abc 时, 有四个前缀:空字符串、a、ab 以及 abc。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given two strings and consisting of lowercase English letters. Determine if is a prefix of .
What is a prefix? A prefix of a string of length is a string expressed as the first characters of , , where is an integer such that . For example, when abc, there are four prefixes of : an empty string, a, ab, and abc.
Constraints
- and are strings of lengths between and (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print Yes
if is a prefix of ; print No
otherwise. Note that the judge is case-sensitive.
Sample Input 1
atco
atcoder
Sample Output 1
Yes
atco
is a prefix of atcoder
. Thus, Yes
should be printed.
Sample Input 2
code
atcoder
Sample Output 2
No
code
is not a prefix of atcoder
. Thus, No
should be printed.
Sample Input 3
abc
abc
Sample Output 3
Yes
Note that a string is also a prefix of itself.
Sample Input 4
aaaa
aa
Sample Output 4
No
update @ 2024/3/10 11:17:47