Problem description: The more people get older, the smarter they get, and the more stupid they get. This is a question that deserves the attention of scientists around the world. Eddy has been thinking about the same problem, when he was very young, he knew how to judge the affinity string. But he found that when he was growing up, he did not know how to judge the affinity string, so he had to ask you again to solve the problem with a smart and helpful person.
The affinity string is defined as follows: Given two strings S1 and S2, if S2 can be contained in S1 through S1 cyclic shift, then S2 is the affinity string of S1.
The input question contains multiple groups of test data. The first line of each group contains the input string S1, the second line contains the input string S2, And the S1 and S2 length are less than 100000.
Output: If S2 is an S1 affinity string, "yes" is output. Otherwise, "no" is output ". The output of each group of tests occupies one row.
Sample Input
AABCDCDAAASDASDF
Sample output
yesno
// In general, it is relatively simple to use KMP questions, and some of them can be solved using the strstr function.
#include <stdio.h>#include <string.h>int main(){ char s1[100005],s2[100005],s[200005]; int len1,len2,i,len; while(scanf("%s%s",s1,s2)!=EOF) { len1 = strlen(s1); len2 = strlen(s2); for(i = 0; i<len1; i++) { s[i] = s1[i]; } for(i = len1; i<2*len1; i++) { s[i] = s1[i-len1]; } s[2*len1] = '\0'; if(strstr(s,s2)) printf("yes\n"); else printf("no\n"); } return 0;}