首页 > 其他 > 详细

poj2752 Seek the Name, Seek the Fame 2012-1-11

时间:2016-03-02 21:58:23      阅读:217      评论:0      收藏:0      [点我收藏+]

http://162.105.81.212/JudgeOnline/problem?id=2752

 

 1 Program Stone;
 2 var i,j,k,n:longint;
 3     b,a:array[1..400000]of longint;
 4     s:ansistring;
 5 Begin
 6  assign(input,input.in);reset(input);
 7    while not(eof) do
 8     begin
 9        readln(s);
10        j:=0;b[1]:=0;
11        for i:=2 to length(s) do
12         begin
13           while (j>0)and(s[i]<>s[j+1]) do j:=b[j];
14           if s[i]=s[j+1] then inc(j);
15           b[i]:=j;
16         end;
17        i:=length(S);
18        k:=0;
19        while i<>0 do
20         begin
21           inc(k);
22           a[k]:=i;
23           i:=b[i];
24         end;
25        for i:=k downto 1 do write(a[i], );
26        writeln;
27     end;
28   close(input);
29 end.

 

poj2752 Seek the Name, Seek the Fame 2012-1-11

原文:http://www.cnblogs.com/yesphet/p/5236450.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!