#P833. Cyclic Shifts

Cyclic Shifts

題目描述

Thuc likes finding cyclic shifts of strings. A cyclic shift of a string is obtained by moving characters from the beginning of the string to the end of the string. We also consider a string to be a cyclic shift of itself. For example, the cyclic shifts of ABCDE are:

ABCDE, BCDEA, CDEAB, DEABC, and EABCD.

Given some text, T, and a string, S, determine if T contains a cyclic shift of S.

輸入格式

The input will consist of exactly two lines containing only uppercase letters. The first line will be the text T, and the second line will be the string S. Each line will contain at most 1000 characters.

輸出格式

Output yes if the text, T, contains a cyclic shift of the string, S. Otherwise, output no.

Samples

["ABCCDEABAA\r\nABCDE","ABCDDEBCAB\r\nABA"]
["yes","no"]

提示

For sample 2:

The cyclic shifts of ABA are ABA, BAA, and AAB. None of these shifts are contained in the text ABCDDEBCAB.

原始資料

  • Zero1 題號:a833
  • Hydro 題號:Z0833
  • Locale:en_US
  • Display:open