首页 > 其他 > 详细

poj1961 Period 2012-01-11

时间:2016-03-02 21:34:33      阅读:124      评论:0      收藏:0      [点我收藏+]

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

_____________________________________

 也是求最长重复字串。
_____________________________________

 1 Program Stone;
 2 var i,j,n,m:longint;
 3     s:ansistring;
 4     b:array[1..1000000]of longint;
 5 Begin
 6  assign(input,input.in);reset(input);
 7    readln(n);
 8    while n<>0 do
 9     begin
10        readln(s);
11        inc(m);
12        j:=0;b[1]:=0;
13        writeln(Test case #,m);
14        for i:=2 to n do
15         begin
16           while (j>0)and(s[i]<>s[j+1]) do j:=b[j];
17           if s[i]=s[j+1] then inc(j);
18           b[i]:=j;
19           if (i mod (i-b[i])=0)and(b[i]<>0) then writeln(i, ,i div (i-b[i]));
20         end;
21        writeln;
22        readln(n);
23     end;
24 end.
25 
26  

 

poj1961 Period 2012-01-11

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

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