## Hdoj / HDU 2203 affinity string (simple judgment of ~ Java indexof() method seconds)

Familiar with memory 2021-01-21 13:47:55
hdoj hdu affinity string simple

Problem Description As people grow older, are they smarter or dumber , This is a question worthy of consideration by scientists all over the world , Same question Eddy I've been thinking about , Because he knew how to judge when he was very young , But found , Now I grow up, but I don't know how to judge , So he had to ask you again to solve the problem . The definition of affinity string is like this ： Given two strings s1 and s2, If you can pass s1 Cyclic shift , send s2 Included in s1 in , So let's say s2 yes s1 Affinity string of .

Input There are many sets of test data , The first line of each set of data contains the input string s1, The second line contains the input string s2,s1 And s2 The length of each of them is less than 100000.

Output If s2 yes s1 Affinity string of , The output ”yes”, conversely , Output ”no”. The output of each test takes up one line .

Sample Input AABCD CDAA ASD ASDF

Sample Output yes no

Water problem ~~

```import java.util.Scanner;
/**
* @author Chen Haoxiang
* 2016-6-5
*/
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String s1=sc.next();
String s2=sc.next();
if(s2.length()>s1.length()){
System.out.println("no");
continue;
}
s1=s1+s1;
if(s1.indexOf(s2)!=-1){
System.out.println("yes");
}else{
System.out.println("no");
}
}
}
}```

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

https://javamana.com/2021/01/20210121134651087m.html