102681: [AtCoder]ABC268 B - Prefix?

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

You are given two strings $S$ and $T$ consisting of lowercase English letters. Determine if $S$ is a prefix of $T$.

What is a prefix? A prefix of a string $T_1T_2\ldots T_N$ of length $N$ is a string expressed as the first $i$ characters of $T$, $T_1T_2\ldots T_i$, where $i$ is an integer such that $0 \leq i \leq N$. For example, when $T = $ abc, there are four prefixes of $T$: an empty string, a, ab, and abc.

Constraints

  • $S$ and $T$ are strings of lengths between $1$ and $100$ (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

$S$
$T$

Output

Print Yes if $S$ is a prefix of $T$; 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

Input

题意翻译

#### 题意 给出两个由小写英文字母组成的字符串 $S$ 和 $T$,判断 $S$ 是否是 $T$ 的前缀。 > #### 什么是前缀? > 一个字符串 $S$ 被称为一个长度为 $N$ 的字符串 $T_{1},T_{2}...T_{n}$ 的前缀, 当且仅当 $S$ 是由 $T_{1},T_{2}...T_{n}$ 的前 $i$ $(1\leq i \leq N)$ 个字母组成的。 #### 数据范围 $S$ 和 $T$ 是长度介于 $1$ 和 $100$ 之间的字符串,且只由小写英文字母组成。 --- #### 输入格式 通过标准输入以以下格式读入数据: ``` S T ``` #### 输出格式 当 $S$ 是 $T$ 的前缀时输出 `Yes`; 否则输出 `No`。注意区分大小写。

Output

得分:200分

问题描述

给你两个由小写英文字母组成的字符串 $S$ 和 $T$。请判断 $S$ 是否是 $T$ 的前缀。

什么是前缀? 一个长度为 $N$ 的字符串 $T_1T_2\ldots T_N$ 的前缀是字符串 $T$ 的前 $i$ 个字符组成的字符串 $T_1T_2\ldots T_i$,其中 $i$ 是一个整数,满足 $0 \leq i \leq N$。例如,当 $T = $ abc 时,$T$ 的前缀有四个:空字符串,a,ab,和 abc。

约束条件

  • $S$ 和 $T$ 是长度在 $1$ 到 $100$(包括 $1$ 和 $100$)之间,由小写英文字母组成的字符串。

输入

输入数据从标准输入以以下格式给出:

$S$
$T$

输出

如果 $S$ 是 $T$ 的前缀,则打印 Yes;否则打印 No。 请注意,裁判区分大小写。


样例输入 1

atco
atcoder

样例输出 1

Yes

atcoatcoder 的前缀。因此应该打印 Yes


样例输入 2

code
atcoder

样例输出 2

No

code 不是 atcoder 的前缀。因此应该打印 No


样例输入 3

abc
abc

样例输出 3

Yes

注意一个字符串本身也是一个自己的前缀。


样例输入 4

aaaa
aa

样例输出 4

No

加入题单

算法标签: