Pro.ID21741 TitleGiven a string. . . Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21741 AC0 Submit0 Ratio- 时间&空间限制描述Peter’s colleague Andrew also works at RIGS. Some time ago Andrew invented another definition of sum of two strings of equal length n. In Andrew’s definition, the basic alphabet to define this operation consists only of zeros and ones. The sum of two strings a + b is just a string c where ci = ai V bi (Si denotes i-th character of string S). Here V stands for usual OR operation which returns 1 if and only if at least one of its arguments is 1. Now Peter must study properties of closure of a given string S. The closure of S (denoted ) is a set of strings S(k) + S(l) for any 0 ≤ k, l ≤ n-1, where n is the length of S, and S(k) denotes an operationof k-th circular shift of S — moving k last characters from the end of the string S to its beginning. For example, the second circular shift of abcde is deabc. Given a string T, Peter’s task is to check whether it belongs to . Could you solve this task for him? 输入The first line of the input file contains a given string T. The second line contains S. Both strings are of equal length in range from 1 to 100 characters. All characters in these strings are zeros or ones. 输出Description Peter’s colleague Andrew also works at RIGS. Some time ago Andrew invented another definition of sum of two strings of equal length n. In Andrew’s definition, the basic alphabet to define this operation consists only of zeros and ones. The sum of two strings a + b is just a string c where ci = ai V bi (Si denotes i-th character of string S). Here V stands for usual OR operation which returns 1 if and only if at least one of its arguments is 1. Now Peter must study properties of closure of a given string S. The closure of S (denoted ) is a set of strings S(k) + S(l) for any 0 ≤ k, l ≤ n-1, where n is the length of S, and S(k) denotes an operationof k-th circular shift of S — moving k last characters from the end of the string S to its beginning. For example, the second circular shift of abcde is deabc. Given a string T, Peter’s task is to check whether it belongs to . Could you solve this task for him? Input The first line of the input file contains a given string T. The second line contains S. Both strings are of equal length in range from 1 to 100 characters. All characters in these strings are zeros or ones. Output If a given string belongs to , output “Yes”. Otherwise output “No”. Sample Input Sample #1 11110 10101 Sample #2 101111 101010 Sample Output Sample #1 Yes Sample #2 No Source 样例输入Sample #1 11110 10101 Sample #2 101111 101010 样例输出Sample #1 Yes Sample #2 No 作者 |