题目: |
var
n,i,j,k:longint;
st:ansistring;
begin
readln(n);
readln(st);
st:=st+st;
i:=1;j:=2;k:=0;
while (i<=n) and (j<=n) and (k<n) do
begin
if i=j then inc(j);
if st[i+k]=st[j+k] then inc(k)
else
if st[i+k]>st[j+k] then
begin
j:=j+k+1;
k:=0;
end
else
begin
i:=i+k+1;
k:=0;
end;
end;
writeln(i);
end.
输入:haishuchusai 输出:9
|