QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#23993. 尋找字串

Statistics

題目描述

給定長度為 $N$ 的字串 $S$、長度為 $M$ 的字串 $T$,以及正整數 $K$。$S$ 與 $T$ 的每個字元皆為小寫英文字母。

設將 $S$ 重複 $K$ 次得到的字串為 $X$。若 $X$ 的子字串包含 $T$ 則輸出 Yes,否則輸出 No。這裡,$X$ 的子字串是指從 $X$ 的開頭刪除 $0$ 個以上的字元、從 $X$ 的末尾刪除 $0$ 個以上的字元後得到的字串。

資料範圍

  • $1 \le N \le 100$。
  • $S$ 是僅由小寫英文字母組成的長度為 $N$ 的字串。
  • $1 \le M \le 100$。
  • $T$ 是僅由小寫英文字母組成的長度為 $M$ 的字串。
  • $1 \le K \le 10^9$。
  • $N, M, K$ 是整數。

子任務

  1. ($25$ 分)$K = 1$。
  2. ($25$ 分)$K \le 100$。
  3. ($25$ 分)$S, T$ 的每個字元皆為 a。
  4. ($25$ 分)無額外限制。

輸入格式

輸入以以下格式給出:

N
S
M
T
K

輸出格式

若 $X$ 的子字串包含 $T$ 則輸出 Yes,否則輸出 No。

除答案外請勿輸出任何內容。(也請勿輸出提示輸入的文字等。)

關於作答格式,可以參考練習題及其解答範例。

範例 1

輸入

4
joig
3
joi
1

輸出

Yes

$X$ 為 joig,其中包含子字串 joi。因此輸出 Yes。

本輸入範例滿足子任務 $1, 2, 4$ 的限制。

範例 2

輸入

3
joi
4
joig
2

輸出

No

$X$ 為 joijoi,其中不包含子字串 joig。因此輸出 No。

本輸入範例滿足子任務 $2, 4$ 的限制。

範例 3

輸入

4
aaaa
1
a
1000000000

輸出

Yes

$X$ 是由 $4 \times 10^9$ 個 a 組成的字串,其中包含子字串 a。因此輸出 Yes。

本輸入範例滿足子任務 $3, 4$ 的限制。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.