zoukankan      html  css  js  c++  java
  • poj2752 水题

    又2b了一次……

     1 var s:ansistring;
     2     ans,pre:array[0..10000] of longint;
     3     i,k,tot:longint;
     4 procedure main;
     5  begin
     6  pre[1]:=0;k:=0;
     7  for i:=2 to length(s) do
     8   begin
     9   while (k<>0) and (s[k+1]<>s[i]) do k:=pre[k];
    10   if s[k+1]=s[i] then inc(k);
    11   pre[i]:=k;
    12   end;
    13  k:=pre[length(s)];
    14  tot:=0;
    15  while k<>0 do
    16   begin
    17   inc(tot);ans[tot]:=k;
    18   k:=pre[k];
    19   end;
    20  for i:=tot downto 1 do write(ans[i],' ');
    21  writeln(length(s));
    22  end;
    23 begin
    24  while true do
    25   begin
    26   readln(s);if s='' then break;
    27   main;
    28   end;
    29 end.                       
    View Code
  • 相关阅读:
    第一次作业
    第0次作业
    第14、15周作业
    第七周作业
    第六周作业
    第四周作业
    第三周作业
    第4次作业
    第3次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/3773203.html
Copyright © 2011-2022 走看看