亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
Input 本题有多组测试数据,每组数据的第一行包含输入字符串s1,第二行包含输入字符串s2,s1与s2的长度均小于100000。
Output 如果s2是s1的亲和串,则输出"yes",反之,输出"no"。每组测试的输出占一行。
Sample Input
AABCD CDAA ASD ASDF
Sample Output
yes no
Author Eddy
就是把第一个串加倍后能不能包含第一个串
kmp模板
#include#include #include #include #include #include #include #include #define L(x) (x<<1) #define R(x) (x<<1|1) #define MID(x,y) ((x+y)>>1) using namespace std; #define N 200005 char a[N],b[N]; int next[N]; void getfail(char *b) { int i,j; i=0,j=-1; next[0]=-1; int len=strlen(b); while(i