Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:为什么RE啊，各路大牛指教！

Posted by 826529615 at 2011-10-16 17:37:40 on Problem 1961
In Reply To:为什么RE啊，各路大牛指教！ Posted by:826529615 at 2011-10-16 17:36:29
```> 交了好几次，都RE.....
> var
>   n, tc: longint;
>   s: ansistring;
>   p: array[0..200010] of longint;
>
> procedure init;
> var
>   i: longint;
> begin
>   if n = 0 then halt;
>   s := '';
> end;
>
> procedure work;
> var
>   i, k, temp: longint;
> begin
>   fillchar(p,sizeof(p),0);
>   k := 0;
>   p[1] := 0;
>   for i := 2 to n do
>     begin
>       while (k > 0) and (s[i] <> s[k+1]) do k := p[k];
>       if s[i] = s[k+1] then inc(k);
>       p[i] := k;
>     end;
>   for i := 1 to n do
>     if p[i] <> 0 then
>       begin
>         temp := i-p[i];
>         if i mod temp = 0 then
>           writeln(i,' ',i div temp);
>       end;
> end;
>
> begin
>   tc := 0;
>   while 1 = 1 do
>     begin
>       inc(tc);
>       init;
>       writeln('Test case #',tc);
>       work;
>       writeln;
>     end;
> end.
```

Followed by: