{"id":264,"date":"2012-11-14T21:06:00","date_gmt":"2012-11-14T13:06:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/169"},"modified":"2012-11-14T21:06:00","modified_gmt":"2012-11-14T13:06:00","slug":"poj_1961_kmp_prefix_longest_repeated_substring","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=264","title":{"rendered":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09"},"content":{"rendered":"<table border=\"0\" width=\"100%\" background=\"http:\/\/poj.org\/images\/table_back.jpg\" style=\"font-family:Simsun\">\n<tbody>\n<tr>\n<td>\n<div style=\"position:absolute; right:10px\">Language:<select size=\"1\"><option value=\"default\" selected=\"selected\"><br \/>\nDefault<\/option><\/select><\/div>\n<div class=\"ptt\" lang=\"en-US\" style=\"text-align:center; font-size:18pt; font-weight:bold; color:blue\">\nPeriod<\/div>\n<div class=\"plm\" style=\"text-align:center; font-size:12pt\">\n<table align=\"center\">\n<tbody>\n<tr>\n<td><strong>Time Limit:<\/strong>&nbsp;3000MS<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Memory Limit:<\/strong>&nbsp;30000K<\/td>\n<\/tr>\n<tr>\n<td><strong>Total Submissions:<\/strong>&nbsp;10179<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Accepted:<\/strong>&nbsp;4662<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nDescription<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u6c42\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\uff0c\u6240\u6709\u5faa\u73af\u8282\u5927\u4e8e2\u7684\u5b50\u4e32\u3002<\/div>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nInput<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u6709\u82e5\u5e72\u7ec4\u6570\u636e\uff0c<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u6bcf\u7ec4\u6570\u636e\u7b2c\u4e00\u884c\u4e3a\u5b57\u7b26\u4e32\u957f\u5ea6\uff0c\u7b2c\u4e8c\u884c\u4e3a\u5b57\u7b26\u4e32<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u4ee50\u7ed3\u675f\u3002<\/div>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nOutput<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u8f93\u51fa'Test case #i&quot;,i\u4ece0\u5f00\u59cb\uff0c\u4e4b\u540e\u6bcf\u884c\u8f93\u51fa\u4e24\u4e2a\u6570\uff0c\u5206\u522b\u8868\u793a\u524d\u7f00\u957f\u5ea6\u548c\u5faa\u73af\u8282\u6570\uff08&gt;1).<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u6bcf\u7ec4\u6570\u636e\u540e\u8f93\u51fa\u4e00\u4e2a\u7a7a\u884c\u3002<\/div>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nSample Input<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">3\naaa\n12\naabaabaabaab\n0<\/pre>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nSample Output<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">Test case #1\n2 2\n3 3\n\nTest case #2\n2 2\n6 2\n9 3\n12 4<\/pre>\n<p class=\"pst\" style=\"text-align:left; font-size:18pt; font-weight:bold; color:blue\">\nSource<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n<a href=\"http:\/\/poj.org\/searchproblem?field=source&amp;key=Southeastern+Europe+2004\" style=\"text-decoration:none\">Southeastern Europe 2004<\/a><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u8fd9\u9898\u5c31\u662fKMP\u95ee\u9898\u3002<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u8fd8\u662fNext\uff0c<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u5148\u505a\u4e0d\u5224\u91cd\u590d\u4f18\u5316\u7684\u5904\u7406<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u89c2\u5bdf\u53d1\u73b0\u82e5\u524d\u9762\u6709\u5faa\u73af\u8282\uff0c\u5219\u6709i-&gt;i-p-&gt;i-2p...-&gt;i-kp=1<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u5219i-next[i]\u8868\u793a\u5faa\u73af\u7ed3\u957f\u5ea6p\uff0c\u663e\u7136\u6709p|\uff08i-1),(i-1) div p&gt;1.<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u5982\u4e0b:<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><\/span><\/p>\n<pre name=\"code\" class=\"delphi\">Program Poj1961;\nconst\n   maxn=10000000;\nvar\n   i,j,tt,n,duan_luo:longint;\n   next:array[1..maxn] of longint;\n   a:ansistring;\nbegin\n   tt:=1;\n   while (true) do\n   begin\n      readln(n);\n      if n=0 then break;\n      readln(a);  inc(n); a:=a+'.';\n      i:=1;j:=0;next[1]:=0;\n      while (i&lt;=n-1) do\n      begin\n         if (j=0) or (a[i]=a[j]) then\n         begin\n             inc(i);inc(j);\n           \/\/  if (a[i]&lt;&gt;a[j]) then next[i]:=j else next[i]:=next[j];\n             next[i]:=j;\n         end\n         else j:=next[j];\n      end;\n\n      writeln('Test case #',tt);\n\n      for i:=2 to n do\n      begin\n         duan_luo:=i-next[i];\n         if (duan_luo&gt;0) and ((i-1) mod duan_luo=0) and ((i-1) div duan_luo&gt;1) then\n            writeln(i-1,' ',(i-1) div duan_luo);\n\n\n\n      end;\n\n\/\/    readln;\n      writeln;\n      inc(tt);\n   end;\n\nend.\n<\/pre>\n<\/p>\n<p>\n<\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><br \/>\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Language: Default Period Time Limit:&nbsp;3000MS &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[34],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-kmp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nike0good.com\/?p=264\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good\" \/>\n<meta property=\"og:description\" content=\"Language: Default Period Time Limit:&nbsp;3000MS &nbsp; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=264\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-14T13:06:00+00:00\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09\",\"datePublished\":\"2012-11-14T13:06:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264\"},\"wordCount\":56,\"commentCount\":0,\"keywords\":[\"KMP\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=264#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=264\",\"name\":\"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"datePublished\":\"2012-11-14T13:06:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=264\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=264#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nike0good.com\/?p=264","og_locale":"zh_CN","og_type":"article","og_title":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good","og_description":"Language: Default Period Time Limit:&nbsp;3000MS &nbsp; [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=264","og_site_name":"nike0good","article_published_time":"2012-11-14T13:06:00+00:00","author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=264#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=264"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09","datePublished":"2012-11-14T13:06:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=264"},"wordCount":56,"commentCount":0,"keywords":["KMP"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=264#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=264","url":"https:\/\/nike0good.com\/?p=264","name":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09 - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"datePublished":"2012-11-14T13:06:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=264#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=264"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=264#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"POJ 1961(KMP\u524d\u7f00\u6700\u957f\u91cd\u590d\u5b50\u4e32\uff09"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=264"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}