题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1305
类型:字典树
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int bj=0;
int s=1;
boolean pd=true;
String str1[]=new String[100000];
while(kb.hasNext()) {
String str=kb.next();
if(str.equals("9")) {
str1=new String[100000];
bj=0;
if(pd)
System.out.println("Set "+s+" is immediately decodable");
else System.out.println("Set "+s+" is not immediately decodable");
s++;
pd=true;
continue;
}
for(int i=0;i<bj;i++) {
if(str.startsWith(str1[i]))pd=false;
}
str1[bj]=str;
bj++;
}
kb.close();
}
}