pku 3852 String LD 模拟,照着做就可以了~

由于题目简单,不写题解了
 1import java.io.*;
 2import java.util.*;
 3public class Main {
 4    static HashSet<String>refer=new HashSet<String>();
 5    static String data[]=new String[101];
 6    static int n=0;
 7    public static void main(String[] args) throws IOException{
 8        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
 9        while(true)
10        {
11            n=Integer.parseInt(in.readLine());
12            if(n==0break;
13            refer.clear();
14            boolean flag=true;
15            for(int i=0;i<n;i++)
16            {
17                data[i]=in.readLine();
18                if(refer.contains(data[i]))
19                    flag=false;
20                else
21                    refer.add(data[i]);
22            }

23            int count=0;
24            for(count=0;flag;count++)
25            {
26                refer.clear();
27                for(int i=0;i<n;i++)
28                {
29                    data[i]=data[i].substring(1);
30                    if(refer.contains(data[i])||data[i].length()==0)
31                        flag=false;
32                    else
33                        refer.add(data[i]);
34                        
35                }

36            }

37            System.out.println(count-1);
38        }

39    }

40}

41
42

posted on 2010-10-14 19:25 yzhw 阅读(170) 评论(0)  编辑 收藏 引用 所属分类: simple problem~


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年10月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

公告

统计系统

留言簿(1)

随笔分类(227)

文章分类(2)

OJ

最新随笔

搜索

积分与排名

最新评论

阅读排行榜