QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100

#23993. 文字列探し (Find The String)

统计

問題文

長さ $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.