{"id":595,"date":"2026-07-08T16:03:12","date_gmt":"2026-07-08T08:03:12","guid":{"rendered":"https:\/\/mitongxue.cn\/?p=595"},"modified":"2026-07-08T16:03:12","modified_gmt":"2026-07-08T08:03:12","slug":"hj65-%e6%9f%a5%e6%89%be%e4%b8%a4%e4%b8%aa%e5%ad%97%e7%ac%a6%e4%b8%b2ab%e4%b8%ad%e7%9a%84%e6%9c%80%e9%95%bf%e5%85%ac%e5%85%b1%e5%ad%90%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/mitongxue.cn\/index.php\/2026\/07\/08\/hj65-%e6%9f%a5%e6%89%be%e4%b8%a4%e4%b8%aa%e5%ad%97%e7%ac%a6%e4%b8%b2ab%e4%b8%ad%e7%9a%84%e6%9c%80%e9%95%bf%e5%85%ac%e5%85%b1%e5%ad%90%e4%b8%b2\/","title":{"rendered":"HJ65\u00a0\u67e5\u627e\u4e24\u4e2a\u5b57\u7b26\u4e32a,b\u4e2d\u7684\u6700\u957f\u516c\u5171\u5b50\u4e32"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u63cf\u8ff0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5bf9\u4e8e\u7ed9\u5b9a\u7684\u4e24\u4e2a\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em>&nbsp;\u548c&nbsp;<math><semantics><mrow><mi>t<\/mi><\/mrow><\/semantics><\/math><em>t<\/em>\uff0c\u4f60\u9700\u8981\u627e\u51fa\u5b83\u4eec\u7684\u6700\u957f\u516c\u5171\u5b50\u4e32\u3002\u7279\u522b\u5730\uff0c\u5982\u679c\u5b58\u5728\u591a\u4e2a\u7b54\u6848\uff0c\u8f93\u51fa\u5728\u8f83\u77ed\u4e32\u4e2d\u6700\u5148\u51fa\u73b0\u7684\u90a3\u4e2a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5b50\u4e32\u4e3a\u4ece\u539f\u5b57\u7b26\u4e32\u4e2d\uff0c\u8fde\u7eed\u7684\u9009\u62e9\u4e00\u6bb5\u5b57\u7b26\uff08\u53ef\u4ee5\u5168\u9009\u3001\u53ef\u4ee5\u4e0d\u9009\uff09\u5f97\u5230\u7684\u65b0\u5b57\u7b26\u4e32\u3002<br><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5982\u679c\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>a<\/mi><\/mrow><\/semantics><\/math><em>a<\/em>&nbsp;\u7684\u4e00\u4e2a\u5b50\u4e32&nbsp;<math><semantics><mrow><msup><mi>a<\/mi><mo mathvariant=\"normal\">\u2032<\/mo><\/msup><\/mrow><\/semantics><\/math><em>a<\/em>\u2032&nbsp;\u4e0e\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>b<\/mi><\/mrow><\/semantics><\/math><em>b<\/em>&nbsp;\u7684\u4e00\u4e2a\u5b50\u4e32&nbsp;<math><semantics><mrow><msup><mi>b<\/mi><mo mathvariant=\"normal\">\u2032<\/mo><\/msup><\/mrow><\/semantics><\/math><em>b<\/em>\u2032&nbsp;\u5b8c\u5168\u76f8\u7b49\uff0c\u90a3\u4e48\u5b50\u4e32&nbsp;<math><semantics><mrow><msup><mi>a<\/mi><mo mathvariant=\"normal\">\u2032<\/mo><\/msup><mo separator=\"true\">,<\/mo><msup><mi>b<\/mi><mo mathvariant=\"normal\">\u2032<\/mo><\/msup><\/mrow><\/semantics><\/math><em>a<\/em>\u2032,<em>b<\/em>\u2032&nbsp;\u662f\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>a<\/mi><mo separator=\"true\">,<\/mo><mi>b<\/mi><\/mrow><\/semantics><\/math><em>a<\/em>,<em>b<\/em>&nbsp;\u7684\u4e00\u4e2a\u516c\u5171\u5b50\u4e32\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u957f\u5ea6\u4e3a&nbsp;<math><semantics><mrow><mn>1<\/mn><mo>\u2266<\/mo><mrow><mi mathvariant=\"normal\">l<\/mi><mi mathvariant=\"normal\">e<\/mi><mi mathvariant=\"normal\">n<\/mi><\/mrow><mo stretchy=\"false\">(<\/mo><mi>s<\/mi><mo stretchy=\"false\">)<\/mo><mo>\u2266<\/mo><mn>300<\/mn><\/mrow><\/semantics><\/math>1\u2266len(<em>s<\/em>)\u2266300\u3001\u4ec5\u7531\u5c0f\u5199\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em>\u3002<br><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u7b2c\u4e8c\u884c\u8f93\u5165\u4e00\u4e2a\u957f\u5ea6\u4e3a&nbsp;<math><semantics><mrow><mn>1<\/mn><mo>\u2266<\/mo><mrow><mi mathvariant=\"normal\">l<\/mi><mi mathvariant=\"normal\">e<\/mi><mi mathvariant=\"normal\">n<\/mi><\/mrow><mo stretchy=\"false\">(<\/mo><mi>t<\/mi><mo stretchy=\"false\">)<\/mo><mo>\u2266<\/mo><mn>300<\/mn><\/mrow><\/semantics><\/math>1\u2266len(<em>t<\/em>)\u2266300\u3001\u4ec5\u7531\u5c0f\u5199\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32&nbsp;<math><semantics><mrow><mi>t<\/mi><\/mrow><\/semantics><\/math><em>t<\/em>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u8f93\u51fa\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u4ee3\u8868&nbsp;<math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em>&nbsp;\u548c&nbsp;<math><semantics><mrow><mi>t<\/mi><\/mrow><\/semantics><\/math><em>t<\/em>&nbsp;\u7684\u6700\u957f\u516c\u5171\u5b50\u4e32\u3002\u5982\u679c\u5b58\u5728\u591a\u4e2a\u7b54\u6848\uff0c\u8f93\u51fa\u5728\u8f83\u77ed\u4e32\u4e2d\u6700\u5148\u51fa\u73b0\u7684\u90a3\u4e2a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awaabb\naawbb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aa<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><math><semantics><mrow><mspace width=\"1.5em\"><\/mspace><\/mrow><\/semantics><\/math>\u5728\u8fd9\u4e2a\u6837\u4f8b\u4e2d\uff0c<math><semantics><mrow><mtext mathvariant=\"monospace\">\"aa\"<\/mtext><\/mrow><\/semantics><\/math>\"aa\" \u548c <math><semantics><mrow><mtext mathvariant=\"monospace\">\"bb\"<\/mtext><\/mrow><\/semantics><\/math>\"bb\" \u90fd\u662f <math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em> \u548c <math><semantics><mrow><mi>t<\/mi><\/mrow><\/semantics><\/math><em>t<\/em> \u7684\u6700\u957f\u516c\u5171\u5b50\u4e32\uff0c\u4f46 <math><semantics><mrow><mtext mathvariant=\"monospace\">\"aa\"<\/mtext><\/mrow><\/semantics><\/math>\"aa\" \u5728\u8f83\u77ed\u4e32 <math><semantics><mrow><mi>s<\/mi><\/mrow><\/semantics><\/math><em>s<\/em> \u4e2d\u9996\u5148\u51fa\u73b0\uff0c\u56e0\u6b64\u8f93\u51fa <math><semantics><mrow><mtext mathvariant=\"monospace\">\"aa\"<\/mtext><\/mrow><\/semantics><\/math>\"aa\"\u3002<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abcdefghijklmnop\nabcsafjklmnopqrstuvw<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jklmnop<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u601d\u8def\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u964d\u4f4e\u5faa\u73af\uff0c\u627e\u51fa\u6700\u77ed\u5b57\u7b26\u4e32<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">2. \u6c42\u51fa\u6700\u77ed\u5b57\u7b26\u4e32\u7b26\u5408\u6761\u4ef6\u7684\u5b50\u4e32\uff08\u5b50\u4e32\u957f\u5ea6\u904d\u5386+\u6ed1\u52a8\u7a97\u53e3\u65b9\u5f0f\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. \u627e\u51fa\u540c\u65f6\u6ee1\u8db3\u957f\u4e32\u7684\u6700\u957f\u5b50\u4e32<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const rl = require(\"readline\").createInterface({ input: process.stdin });\nvar iter = rl&#91;Symbol.asyncIterator]();\nconst readline = async () => (await iter.next()).value;\n\nvoid async function () {\n    \/\/ Write your code here\n    const s = await readline();\n    const t = await readline();\n    const minL = Math.min(s.length, t.length);\n    const minStr = s.length === minL ? s : t;\n    const maxStr = s.length === minL ? t : s;\n    \/\/console.log(minL,'minL');\n    let longStr = \"\";\n    let longStrLen = 0;\n    \/\/const res = &#91;];\n    for(let i=2;i&lt;minL;i++){\n        for(let j=0;j&lt;minL-1;j++){\n            const subStr = minStr.slice(j,j+i);\n            \/\/res.push(minStr.slice(j,j+i));\n            if(maxStr.includes(subStr)){\n                if(subStr.length > longStrLen){\n                    longStr = subStr;\n                    longStrLen = subStr.length;\n                }\n                \/\/res.push(subStr);\n            }\n        }\n    }\n    console.log(longStr); \n}()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63cf\u8ff0 \u5bf9\u4e8e\u7ed9\u5b9a\u7684\u4e24\u4e2a\u5b57\u7b26\u4e32&nbsp;ss&#038;nbs..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,11],"tags":[],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-js","category-front"],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"author_info":{"info":["\u9648 \u67d0\u4eba"]},"category_info":"<a href=\"https:\/\/mitongxue.cn\/index.php\/category\/front\/js\/\" rel=\"category tag\">JS<\/a> <a href=\"https:\/\/mitongxue.cn\/index.php\/category\/front\/\" rel=\"category tag\">\u524d\u7aef<\/a>","tag_info":"\u524d\u7aef","comment_count":"0","_links":{"self":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":1,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":596,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/595\/revisions\/596"}],"wp:attachment":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}