import java.util.*;
public class Main {
public static void main(String args[]){
Scanner in=new Scanner(System.in);
while(in.hasNext()){
String str=in.nextLine();
boolean flag1=f1(str);
boolean flag2=f2(str);
boolean flag3=f3(str);
/*System.out.println(flag1+" "+flag2+" "+flag3);*/
if(flag1 && flag2 && flag3){
System.out.println("Likes");
}else{
System.out.println("Dislikes");
}
}
}
//判断是否不符合第一中不喜欢的类型
public static boolean f1(String str){
char ch[]=str.toCharArray();
for(int i=0;i<ch.length-1;i++){
if(ch[i]==ch[i+1])
return false;
}
return true;
}
//判断是否是不符合第二种不喜欢的类型
public static boolean f2(String str){
char ch[]=str.toCharArray();
int posi,posj;
for(int i=0;i<ch.length-3;i++){
for(int j=i+1;j<ch.length-2;j++){
String newstr=str.substring(j+1,str.length());
posi=newstr.indexOf(ch[i]);
posj=newstr.indexOf(ch[j]);
if(posi<posj &&posi!=-1){
return false;
}
}
}
return true;
}
//判断是否是不符合第三种不喜欢的类型
public static boolean f3(String str){
if(str.length()>78){
return false;
}else{
char ch[]=str.toCharArray();
int cnt[]=new int[26];
int pos;
for(int i=0;i<ch.length;i++){
pos=ch[i]-'A';
cnt[pos]++;
if(cnt[pos]>=4){
return false;
}
}
}
return true;
}
}
牛客网题解-小易喜欢的单词
猜你喜欢
转载自blog.csdn.net/anhuibozhoushatu/article/details/83892763
今日推荐
周排行