Problem Description
亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
Input
Output
Sample Input
AABCD CDAA ASD ASDF
Sample Output
yes no
code:
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner reader = new Scanner(System.in);
while(reader.hasNext())
{
String str1 = reader.next();
String str2 = reader.next();
if(str1.length()<str2.length())
{
System.out.println("no");
continue;
}
str1 = str1+str1;
if(str1.indexOf(str2)<0)
{
System.out.println("no");
}
else
{
System.out.println("yes");
}
}
}
}
2万+



被折叠的 条评论
为什么被折叠?



