Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么RE啊,各路大牛指教!交了好几次,都RE..... var n, tc: longint; s: ansistring; p: array[0..200010] of longint; procedure init; var i: longint; begin readln(n); if n = 0 then halt; s := ''; readln(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:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator