{"id":937,"date":"2026-03-22T13:09:32","date_gmt":"2026-03-22T05:09:32","guid":{"rendered":"https:\/\/vite66.cn\/?p=937"},"modified":"2026-03-22T13:23:46","modified_gmt":"2026-03-22T05:23:46","slug":"%e6%95%b4%e6%95%b0%e6%97%a0%e5%ba%8f%e5%88%86%e6%8b%86","status":"publish","type":"post","link":"https:\/\/vite66.cn\/?p=937","title":{"rendered":"\u6574\u6570\u65e0\u5e8f\u5206\u62c6"},"content":{"rendered":"<h2>1. \u95ee\u9898\u5f62\u5f0f\u5316\u5b9a\u4e49<\/h2>\n<h3>1.1 \u9898\u76ee\u539f\u63cf\u8ff0<\/h3>\n<p>\u5c06  $M$  \u4e2a\u76f8\u540c\u7684\u82f9\u679c\u653e\u5165  $N$  \u4e2a\u76f8\u540c\u7684\u76d8\u5b50\u4e2d\uff0c\u5141\u8bb8\u76d8\u5b50\u4e3a\u7a7a\uff0c\u4e0d\u533a\u5206\u76d8\u5b50\u7684\u987a\u5e8f\uff08\u5982\u5206\u62c6  $[5,1,1]$  \u4e0e  $[1,5,1]$  \u89c6\u4e3a\u540c\u4e00\u79cd\uff09\uff0c\u6c42\u4e0d\u540c\u7684\u5206\u6cd5\u603b\u6570  $K$ \u3002<\/p>\n<h3>1.2 \u6570\u5b66\u5efa\u6a21<\/h3>\n<p>\u8be5\u95ee\u9898\u7b49\u4ef7\u4e8e<strong>\u7ec4\u5408\u6570\u5b66\u4e2d\u7684\u6574\u6570\u65e0\u5e8f\u5206\u62c6\u95ee\u9898<\/strong>\uff1a<\/p>\n<p>\u7ed9\u5b9a\u975e\u8d1f\u6574\u6570  $M$ \uff08\u88ab\u5206\u62c6\u6570\uff09\u4e0e\u6b63\u6574\u6570  $N$ \uff08\u5206\u62c6\u7684\u6700\u5927\u90e8\u5206\u6570\uff09\uff0c\u6c42\u5c06  $M$  \u5206\u62c6\u4e3a<strong>\u81f3\u591a <\/strong> $N$  <strong> \u4e2a\u975e\u8d1f\u6574\u6570\u7684\u65e0\u5e8f\u5206\u62c6<\/strong>\u7684\u6570\u76ee\u3002\u5176\u4e2d\uff0c\u5206\u62c6\u7684\u4efb\u610f\u6392\u5217\u89c6\u4e3a\u540c\u4e00\u4e2a\u5206\u62c6\uff0c\u4ec5\u7531\u5143\u7d20\u7684\u591a\u91cd\u96c6\u5408\u51b3\u5b9a\u3002<\/p>\n<p>\u4e3a\u7b80\u5316\u5206\u6790\uff0c\u5b9a\u4e49\u6838\u5fc3\u8ba1\u6570\u51fd\u6570\uff1a<\/p>\n<p>$f(m,n) = \\text{\u5c06 } m \\text{ \u4e2a\u82f9\u679c\u653e\u5165 } n \\text{ \u4e2a\u76f8\u540c\u76d8\u5b50\u7684\u5206\u6cd5\u603b\u6570}$ <\/p>\n<p>\u6211\u4eec\u7684\u76ee\u6807\u662f\u5bf9\u7ed9\u5b9a\u7684  $M,N$ \uff0c\u8ba1\u7b97  $f(M,N)$ \u3002<\/p>\n<hr \/>\n<h2>2. \u6838\u5fc3\u539f\u7406\uff1a\u65e0\u5e8f\u5206\u62c6\u7684\u53bb\u91cd\u4e0e\u53cc\u5c04\u8bc1\u660e<\/h2>\n<p>\u65e0\u5e8f\u5206\u62c6\u7684\u6838\u5fc3\u96be\u70b9\u662f<strong>\u907f\u514d\u91cd\u590d\u8ba1\u6570<\/strong>\uff0c\u5176\u672c\u8d28\u662f\u6d88\u9664\u6392\u5217\u5e26\u6765\u7684\u5197\u4f59\u3002\u6211\u4eec\u901a\u8fc7\u4ee5\u4e0b\u5b9a\u7406\u89e3\u51b3\u8be5\u95ee\u9898\uff1a<\/p>\n<h3>\u5b9a\u74061\uff1a\u65e0\u5e8f\u5206\u62c6\u4e0e\u975e\u9012\u589e\u5e8f\u5217\u7684\u4e00\u4e00\u5bf9\u5e94<\/h3>\n<p>\u4efb\u610f\u4e00\u4e2a\u5c06  $m$  \u5206\u62c6\u4e3a\u81f3\u591a  $n$  \u4e2a\u975e\u8d1f\u6574\u6570\u7684\u65e0\u5e8f\u5206\u62c6\uff0c<strong>\u552f\u4e00\u5bf9\u5e94\u4e00\u4e2a\u957f\u5ea6\u4e3a <\/strong> $n$  <strong> \u7684\u975e\u9012\u589e\u975e\u8d1f\u6574\u6570\u5e8f\u5217<\/strong>\uff1b\u53cd\u4e4b\uff0c\u4efb\u610f\u4e00\u4e2a\u957f\u5ea6\u4e3a  $n$  \u7684\u975e\u9012\u589e\u975e\u8d1f\u6574\u6570\u5e8f\u5217\uff0c\u552f\u4e00\u5bf9\u5e94\u4e00\u4e2a\u65e0\u5e8f\u5206\u62c6\u3002<\/p>\n<h4>\u8bc1\u660e<\/h4>\n<ol>\n<li>\n<p><strong>\u6b63\u5411\u6620\u5c04<\/strong>\uff1a\u5bf9\u4efb\u610f\u65e0\u5e8f\u5206\u62c6\uff0c\u5c06\u5176\u5143\u7d20\u6309\u975e\u9012\u589e\u987a\u5e8f\u6392\u5e8f\uff0c\u88650\u81f3\u957f\u5ea6\u4e3a  $n$ \uff0c\u5f97\u5230\u552f\u4e00\u7684\u975e\u9012\u589e\u5e8f\u5217\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u53cd\u5411\u6620\u5c04<\/strong>\uff1a\u5bf9\u4efb\u610f\u957f\u5ea6\u4e3a  $n$  \u7684\u975e\u9012\u589e\u975e\u8d1f\u6574\u6570\u5e8f\u5217\uff0c\u5176\u5143\u7d20\u7684\u591a\u91cd\u96c6\u5408\u552f\u4e00\u5bf9\u5e94\u4e00\u4e2a\u65e0\u5e8f\u5206\u62c6\u3002<\/p>\n<\/li>\n<li>\n<p>\u8be5\u6620\u5c04\u4e3a\u53cc\u5c04\uff08\u4e00\u4e00\u5bf9\u5e94\uff09\uff0c\u56e0\u6b64\u5bf9\u65e0\u5e8f\u5206\u62c6\u7684\u8ba1\u6570\uff0c\u7b49\u4ef7\u4e8e\u5bf9\u6ee1\u8db3\u6761\u4ef6\u7684\u975e\u9012\u589e\u5e8f\u5217\u7684\u8ba1\u6570\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u8be5\u5b9a\u7406\u662f\u6240\u6709\u89e3\u6cd5\u7684\u6838\u5fc3\u57fa\u7840\uff1a\u901a\u8fc7\u5f3a\u5236\u5e8f\u5217\u975e\u9012\u589e\uff0c\u4ece\u6839\u6e90\u4e0a\u6d88\u9664\u6392\u5217\u5e26\u6765\u7684\u91cd\u590d\u8ba1\u6570\uff0c\u4fdd\u8bc1\u8ba1\u6570\u7684\u4e0d\u91cd\u4e0d\u6f0f\u3002<\/p>\n<hr \/>\n<h2>3. \u89e3\u6cd5\u4e00\uff1a\u66b4\u529bDFS\u679a\u4e3e\u6cd5\uff08\u6a21\u62df\u6cd5\uff09<\/h2>\n<h3>3.1 \u7b97\u6cd5\u601d\u8def<\/h3>\n<p>\u57fa\u4e8e\u5b9a\u74061\uff0c\u901a\u8fc7\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\uff08DFS\uff09\u9012\u5f52\u6784\u9020\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u7684\u975e\u9012\u589e\u5e8f\u5217\uff1a<\/p>\n<ol>\n<li>\n<p>\u5e8f\u5217\u957f\u5ea6\u4e3a  $N$ \uff08\u76d8\u5b50\u603b\u6570\uff09\uff1b<\/p>\n<\/li>\n<li>\n<p>\u5e8f\u5217\u5143\u7d20\u975e\u9012\u589e\uff08\u540e\u4e00\u4e2a\u5143\u7d20 \u2264 \u524d\u4e00\u4e2a\u5143\u7d20\uff09\uff1b<\/p>\n<\/li>\n<li>\n<p>\u5e8f\u5217\u5143\u7d20\u4e4b\u548c\u4e3a  $M$ \uff08\u82f9\u679c\u603b\u6570\uff09\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u9012\u5f52\u51fd\u6570\u5b9a\u4e49\u4e3a\uff1a<\/p>\n<p>$dfs(rest, last, idx) = \\text{\u5269\u4f59 } rest \\text{ \u4e2a\u82f9\u679c\uff0c\u5f53\u524d\u76d8\u5b50\u6700\u591a\u653e } last \\text{ \u4e2a\uff0c\u6b63\u5728\u653e\u7b2c } idx \\text{ \u4e2a\u76d8\u5b50\u7684\u5206\u6cd5\u6570}$ <\/p>\n<h3>3.2 \u6b63\u786e\u6027\u8bc1\u660e<\/h3>\n<p>\u7531\u5b9a\u74061\uff0c\u6240\u6709\u5408\u6cd5\u5206\u62c6\u4e0e\u6ee1\u8db3\u6761\u4ef6\u7684\u975e\u9012\u589e\u5e8f\u5217\u4e00\u4e00\u5bf9\u5e94\u3002DFS\u679a\u4e3e\u4e86\u6240\u6709\u6ee1\u8db3\u975e\u9012\u589e\u7ea6\u675f\u3001\u548c\u4e3a  $M$  \u7684\u957f\u5ea6\u4e3a  $N$  \u7684\u5e8f\u5217\uff0c\u56e0\u6b64\u8ba1\u6570\u7ed3\u679c\u4e0d\u91cd\u4e0d\u6f0f\uff0c\u4e0e  $f(M,N)$  \u7b49\u4ef7\u3002<\/p>\n<h3>3.3 \u590d\u6742\u5ea6\u5206\u6790<\/h3>\n<ul>\n<li>\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a\u6307\u6570\u7ea7  $O(e^{\\pi\\sqrt{2M\/3}})$ \uff0c\u4e0e\u6574\u6570\u5206\u62c6\u6570\u7684\u6e10\u8fd1\u589e\u957f\u4e00\u81f4\u3002\u9012\u5f52\u8fc7\u7a0b\u65e0\u7f13\u5b58\uff0c\u5b58\u5728\u5927\u91cf\u91cd\u590d\u5b50\u95ee\u9898\u8ba1\u7b97\uff0c\u4ec5\u80fd\u5904\u7406  $M,N \\leq 15$  \u7684\u6781\u5c0f\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7a7a\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a $O(N)$ \uff0c\u4e3a\u9012\u5f52\u6808\u7684\u6df1\u5ea6\uff08\u6700\u591a\u9012\u5f52  $N$  \u5c42\uff09\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>4. \u89e3\u6cd5\u4e8c\uff1a\u8bb0\u5fc6\u5316\u641c\u7d22\u6cd5<\/h2>\n<h3>4.1 \u9012\u63a8\u5173\u7cfb\u7684\u4e25\u8c28\u63a8\u5bfc\u4e0e\u8bc1\u660e<\/h3>\n<p>\u6211\u4eec\u901a\u8fc7\u5206\u60c5\u51b5\u8ba8\u8bba\uff0c\u63a8\u5bfc  $f(m,n)$  \u7684\u9012\u63a8\u5173\u7cfb\uff0c\u5e76\u901a\u8fc7\u53cc\u5c04\u8bc1\u660e\u5176\u6b63\u786e\u6027\u3002<\/p>\n<h4>4.1.1 \u8fb9\u754c\u6761\u4ef6<\/h4>\n<ol>\n<li>\n<p>\u5f53  $m=0$  \u65f6\uff1a\u4ec5\u5b58\u57281\u79cd\u5206\u6cd5\uff08\u6240\u6709\u76d8\u5b50\u4e3a\u7a7a\uff09\uff0c\u56e0\u6b64  $f(0,n)=1, \\forall n \\geq 0$ \u3002<\/p>\n<\/li>\n<li>\n<p>\u5f53  $n=0$  \u65f6\uff1a\u4ec5\u5f53  $m=0$  \u65f6\u67091\u79cd\u5206\u6cd5\uff0c\u5426\u5219\u65e0\u6cd5\u653e\u7f6e\uff0c\u56e0\u6b64  $f(m,0)=0, \\forall m &gt; 0$ \u3002<\/p>\n<\/li>\n<\/ol>\n<h4>4.1.2 \u6838\u5fc3\u9012\u63a8\u5f0f<\/h4>\n<p><strong>\u60c5\u51b51\uff1a<\/strong> $n &gt; m$  <strong>\uff08\u76d8\u5b50\u6570 &gt; \u82f9\u679c\u6570\uff09<\/strong><\/p>\n<p>\u6b64\u65f6\u6709  $f(m,n) = f(m,m)$ \u3002<\/p>\n<h5>\u8bc1\u660e<\/h5>\n<p>\u8bbe  $S$  \u4e3a  $m$  \u4e2a\u82f9\u679c\u653e\u5165  $n$  \u4e2a\u76d8\u5b50\u7684\u5206\u62c6\u96c6\u5408\uff0c $T$  \u4e3a  $m$  \u4e2a\u82f9\u679c\u653e\u5165  $m$  \u4e2a\u76d8\u5b50\u7684\u5206\u62c6\u96c6\u5408\u3002<\/p>\n<ul>\n<li>\n<p>\u5bf9\u4efb\u610f\u5206\u62c6  $s \\in S$ \uff0c\u56e0  $m &lt; n$ \uff0c\u5e8f\u5217\u4e2d\u81f3\u5c11\u6709  $n-m$  \u4e2a0\uff0c\u53bb\u6389\u672b\u5c3e\u7684  $n-m$  \u4e2a0\uff0c\u5f97\u5230\u957f\u5ea6\u4e3a  $m$  \u7684\u975e\u9012\u589e\u5e8f\u5217  $s' \\in T$ \u3002<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4efb\u610f\u5206\u62c6  $s' \\in T$ \uff0c\u5728\u672b\u5c3e\u8865  $n-m$  \u4e2a0\uff0c\u5f97\u5230\u957f\u5ea6\u4e3a  $n$  \u7684\u975e\u9012\u589e\u5e8f\u5217  $s \\in S$ \u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8be5\u6620\u5c04\u4e3a\u53cc\u5c04\uff0c\u56e0\u6b64  $|S|=|T|$ \uff0c\u5373  $f(m,n)=f(m,m)$ \u3002<\/p>\n<hr \/>\n<p><strong>\u60c5\u51b52\uff1a<\/strong> $n \\leq m$  <strong>\uff08\u76d8\u5b50\u6570 \u2264 \u82f9\u679c\u6570\uff09<\/strong><\/p>\n<p>\u6b64\u65f6\u6709  $f(m,n) = f(m,n-1) + f(m-n,n)$ \u3002<\/p>\n<h5>\u8bc1\u660e<\/h5>\n<p>\u5c06\u6240\u6709\u5206\u62c6\u5212\u5206\u4e3a\u4e24\u4e2a\u4e0d\u4ea4\u7684\u5b50\u96c6\uff1a<\/p>\n<ol>\n<li><strong>\u5b50\u96c6A\uff1a\u81f3\u5c11\u67091\u4e2a\u76d8\u5b50\u4e3a\u7a7a<\/strong><\/li>\n<\/ol>\n<p>\u53bb\u63891\u4e2a\u7a7a\u76d8\u5b50\uff0c\u5206\u62c6\u4e0e\u300c $m$  \u4e2a\u82f9\u679c\u653e\u5165  $n-1$  \u4e2a\u76d8\u5b50\u300d\u7684\u5206\u62c6\u4e00\u4e00\u5bf9\u5e94\uff0c\u56e0\u6b64  $|A|=f(m,n-1)$ \u3002<\/p>\n<ol>\n<li><strong>\u5b50\u96c6B\uff1a\u6240\u6709\u76d8\u5b50\u975e\u7a7a\uff08\u6bcf\u4e2a\u76d8\u5b50\u81f3\u5c111\u4e2a\u82f9\u679c\uff09<\/strong><\/li>\n<\/ol>\n<p>\u7ed9\u6bcf\u4e2a\u76d8\u5b50\u5148\u653e1\u4e2a\u82f9\u679c\uff0c\u5269\u4f59  $m-n$  \u4e2a\u82f9\u679c\uff0c\u5206\u62c6\u4e0e\u300c $m-n$  \u4e2a\u82f9\u679c\u653e\u5165  $n$  \u4e2a\u76d8\u5b50\u300d\u7684\u5206\u62c6\u4e00\u4e00\u5bf9\u5e94\uff0c\u56e0\u6b64  $|B|=f(m-n,n)$ \u3002<\/p>\n<p>\u56e0  $A \\cup B$  \u4e3a\u5168\u96c6\uff0c\u4e14  $A \\cap B = \\emptyset$ \uff0c\u6545  $f(m,n)=|A|+|B|=f(m,n-1)+f(m-n,n)$ \u3002<\/p>\n<h3>4.2 \u7b97\u6cd5\u5b9e\u73b0\u601d\u8def<\/h3>\n<p>\u5728\u7eaf\u9012\u5f52\u7684\u57fa\u7840\u4e0a\uff0c\u5f15\u5165\u4e8c\u7ef4\u7f13\u5b58\u6570\u7ec4 <code>memo[m][n]<\/code>\uff0c\u8bb0\u5f55\u5df2\u7ecf\u8ba1\u7b97\u8fc7\u7684  $f(m,n)$ \uff0c\u907f\u514d\u91cd\u590d\u5b50\u95ee\u9898\u7684\u8ba1\u7b97\u3002\u9012\u5f52\u65f6\u82e5 <code>memo[m][n]<\/code> \u5df2\u8ba1\u7b97\uff0c\u76f4\u63a5\u8fd4\u56de\u7f13\u5b58\u503c\uff0c\u5426\u5219\u8ba1\u7b97\u540e\u5b58\u5165\u7f13\u5b58\u3002<\/p>\n<h3>4.3 \u590d\u6742\u5ea6\u5206\u6790<\/h3>\n<ul>\n<li>\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a\u591a\u9879\u5f0f\u7ea7  $O(M \\times N)$ \u3002\u72b6\u6001\u603b\u6570\u4e3a  $(M+1) \\times (N+1)$ \uff0c\u6bcf\u4e2a\u72b6\u6001\u4ec5\u8ba1\u7b971\u6b21\uff0c\u6bcf\u6b21\u8ba1\u7b97\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a  $O(1)$ \u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7a7a\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a $O(M \\times N)$ \uff0c\u4e3a\u7f13\u5b58\u6570\u7ec4\u7684\u7a7a\u95f4\u5f00\u9500\uff0c\u53e0\u52a0  $O(N)$  \u7684\u9012\u5f52\u6808\u5f00\u9500\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>5. \u89e3\u6cd5\u4e09\uff1a\u52a8\u6001\u89c4\u5212\uff08DP\uff09\u8fed\u4ee3\u6cd5<\/h2>\n<h3>5.1 \u7b97\u6cd5\u601d\u8def\u4e0e\u586b\u8868\u903b\u8f91<\/h3>\n<p>\u52a8\u6001\u89c4\u5212\u662f\u8bb0\u5fc6\u5316\u641c\u7d22\u7684\u8fed\u4ee3\u5b9e\u73b0\uff0c\u901a\u8fc7\u81ea\u5e95\u5411\u4e0a\u7684\u65b9\u5f0f\u586b\u5145DP\u8868\uff0c\u907f\u514d\u9012\u5f52\u6808\u5f00\u9500\u3002<\/p>\n<ol>\n<li>\n<p><strong>DP\u6570\u7ec4\u5b9a\u4e49<\/strong>\uff1a<code>dp[i][j] = f(i,j)<\/code>\uff0c\u5373  $i$  \u4e2a\u82f9\u679c\u653e\u5165  $j$  \u4e2a\u76d8\u5b50\u7684\u5206\u6cd5\u603b\u6570\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u521d\u59cb\u5316<\/strong>\uff1a\u6309\u8fb9\u754c\u6761\u4ef6\u521d\u59cb\u5316DP\u8868\uff1a<\/p>\n<ul>\n<li>\n<p><code>dp[0][j] = 1<\/code>\uff0c\u5bf9\u6240\u6709  $0 \\leq j \\leq N$ \uff1b<\/p>\n<\/li>\n<li>\n<p><code>dp[i][1] = 1<\/code>\uff0c\u5bf9\u6240\u6709  $0 \\leq i \\leq M$ \u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u586b\u8868\u987a\u5e8f<\/strong>\uff1a\u6309\u82f9\u679c\u6570  $i$  \u4ece1\u5230  $M$  \u9012\u589e\uff0c\u76d8\u5b50\u6570  $j$  \u4ece2\u5230  $N$  \u9012\u589e\uff0c\u4fdd\u8bc1\u8ba1\u7b97 <code>dp[i][j]<\/code> \u65f6\uff0c\u5176\u4f9d\u8d56\u7684 <code>dp[i][j-1]<\/code> \u548c <code>dp[i-j][j]<\/code> \u5df2\u5b8c\u6210\u8ba1\u7b97\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u72b6\u6001\u8f6c\u79fb<\/strong>\uff1a<\/p>\n<\/li>\n<\/ol>\n<p>dp[i][j] =  \\begin{cases} dp[i][i] &amp; j &gt; i \\ dp[i][j-1] + dp[i-j][j] &amp; j \\leq i \\end{cases}<\/p>\n<h3>5.2 \u6b63\u786e\u6027\u8bc1\u660e<\/h3>\n<p>DP\u8868\u7684\u586b\u5145\u5b8c\u5168\u9075\u5faa4.1\u8282\u4e2d\u4e25\u683c\u8bc1\u660e\u7684\u9012\u63a8\u5173\u7cfb\u4e0e\u8fb9\u754c\u6761\u4ef6\uff0c\u81ea\u5e95\u5411\u4e0a\u7684\u8ba1\u7b97\u987a\u5e8f\u4fdd\u8bc1\u4e86\u6240\u6709\u4f9d\u8d56\u72b6\u6001\u7684\u63d0\u524d\u6c42\u89e3\uff0c\u56e0\u6b64\u6700\u7ec8 <code>dp[M][N]<\/code> \u4e0e  $f(M,N)$  \u5b8c\u5168\u7b49\u4ef7\u3002<\/p>\n<h3>5.3 \u590d\u6742\u5ea6\u5206\u6790<\/h3>\n<ul>\n<li>\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a\u591a\u9879\u5f0f\u7ea7  $O(M \\times N)$ \uff0c\u4e0e\u8bb0\u5fc6\u5316\u641c\u7d22\u4e00\u81f4\uff0c\u65e0\u9012\u5f52\u5e38\u6570\u5f00\u9500\uff0c\u5b9e\u9645\u8fd0\u884c\u6548\u7387\u66f4\u9ad8\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7a7a\u95f4\u590d\u6742\u5ea6<\/strong>\uff1a $O(M \\times N)$ \uff0c\u53ef\u901a\u8fc7\u6eda\u52a8\u6570\u7ec4\u4f18\u5316\u81f3  $O(M)$ \uff0c\u57fa\u7840\u5b9e\u73b0\u65e0\u9700\u4f18\u5316\u5373\u53ef\u6ee1\u8db3\u9898\u76ee\u7ea6\u675f\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>6. \u4e09\u79cd\u89e3\u6cd5\u7684\u7efc\u5408\u5bf9\u6bd4<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u89e3\u6cd5<\/th>\n<th>\u65f6\u95f4\u590d\u6742\u5ea6<\/th>\n<th>\u7a7a\u95f4\u590d\u6742\u5ea6<\/th>\n<th>\u6838\u5fc3\u4f18\u52bf<\/th>\n<th>\u6838\u5fc3\u7f3a\u9677<\/th>\n<th>\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u66b4\u529bDFS\u679a\u4e3e<\/td>\n<td>\u6307\u6570\u7ea7<\/td>\n<td>$O(N)$<\/td>\n<td>\u903b\u8f91\u76f4\u89c2\uff0c\u5b8c\u5168\u8d34\u5408\u5206\u62c6\u7684\u6784\u9020\u8fc7\u7a0b\uff0c\u6613\u7406\u89e3<\/td>\n<td>\u65f6\u95f4\u590d\u6742\u5ea6\u8fc7\u9ad8\uff0c\u4ec5\u80fd\u5904\u7406\u6781\u5c0f\u6570\u636e<\/td>\n<td>\u7b97\u6cd5\u5165\u95e8\u6559\u5b66\uff0c\u5206\u62c6\u539f\u7406\u6f14\u793a<\/td>\n<\/tr>\n<tr>\n<td>\u8bb0\u5fc6\u5316\u641c\u7d22<\/td>\n<td>$O(M \\times N)$<\/td>\n<td>$O(M \\times N)$<\/td>\n<td>\u517c\u987e\u9012\u5f52\u7684\u53ef\u8bfb\u6027\u4e0e\u591a\u9879\u5f0f\u7ea7\u6548\u7387\uff0c\u4ee3\u7801\u6613\u5199<\/td>\n<td>\u5b58\u5728\u9012\u5f52\u6808\u6ea2\u51fa\u98ce\u9669\uff0c\u9012\u5f52\u8c03\u7528\u6709\u5e38\u6570\u5f00\u9500<\/td>\n<td>\u7ade\u8d5b\u5feb\u901f\u5b9e\u73b0\uff0c\u539f\u7406\u8fc7\u6e21\u5b66\u4e60<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u6001\u89c4\u5212\u8fed\u4ee3<\/td>\n<td>$O(M \\times N)$<\/td>\n<td>$O(M \\times N)$<\/td>\n<td>\u6548\u7387\u6700\u9ad8\uff0c\u65e0\u9012\u5f52\u98ce\u9669\uff0c\u662f\u8be5\u95ee\u9898\u7684\u6807\u51c6\u89e3\u6cd5<\/td>\n<td>\u9700\u63d0\u524d\u7406\u89e3\u72b6\u6001\u8f6c\u79fb\u65b9\u7a0b\uff0c\u5bf9\u65b0\u624b\u76f4\u89c2\u6027\u8f83\u5f31<\/td>\n<td>\u6b63\u5f0f\u8003\u8bd5\/\u7ade\u8d5b\uff0c\u5de5\u7a0b\u5316\u5b9e\u73b0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>7. \u95ee\u9898\u53d8\u4f53\u4e0e\u62d3\u5c55<\/h2>\n<ol>\n<li>\n<p><strong>\u76d8\u5b50\u4e0d\u5141\u8bb8\u4e3a\u7a7a<\/strong>\uff1a\u7b49\u4ef7\u4e8e\u5c06  $M$  \u5206\u62c6\u4e3a\u6070\u597d  $N$  \u4e2a\u6b63\u6574\u6570\u7684\u5206\u62c6\u6570\uff0c\u7ed3\u679c\u4e3a  $f(M-N, N)$ \uff08\u5148\u7ed9\u6bcf\u4e2a\u76d8\u5b50\u653e1\u4e2a\u82f9\u679c\uff0c\u5269\u4f59  $M-N$  \u4e2a\u81ea\u7531\u5206\u62c6\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u76d8\u5b50\u53ef\u533a\u5206<\/strong>\uff1a\u7b49\u4ef7\u4e8e\u53ef\u91cd\u7ec4\u5408\u95ee\u9898\uff0c\u7528\u9694\u677f\u6cd5\u6c42\u89e3\uff0c\u7ed3\u679c\u4e3a  $\\binom{M+N-1}{N-1}$ \uff0c\u4e0e\u65e0\u5e8f\u5206\u62c6\u7684\u6838\u5fc3\u533a\u522b\u662f\u6392\u5217\u89c6\u4e3a\u4e0d\u540c\u5206\u62c6\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u751f\u6210\u51fd\u6570\u8868\u793a<\/strong>\uff1a $f(M,N)$  \u662f\u751f\u6210\u51fd\u6570  $F(x) = \\prod_{k=1}^N \\frac{1}{1-x^k}$  \u5c55\u5f00\u540e  $x^M$  \u9879\u7684\u7cfb\u6570\uff0c\u8be5\u7ed3\u8bba\u662f\u6574\u6570\u5206\u62c6\u7684\u6838\u5fc3\u751f\u6210\u51fd\u6570\u7406\u8bba\u3002<\/p>\n<\/li>\n<\/ol>\n<hr \/>\n<h2>8. \u6807\u51c6\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<h3>8.1 \u66b4\u529bDFS\u679a\u4e3e\u6cd5<\/h3>\n<pre><code class=\"language-C++\">\n#include &lt;iostream&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint dfs(int rest, int last, int idx, int total_plate) {\n    if (idx == total_plate) return rest == 0 ? 1 : 0;\n    int count = 0;\n    for (int i = 0; i &lt;= min(last, rest); ++i) {\n        count += dfs(rest - i, i, idx + 1, total_plate);\n    }\n    return count;\n}\n\nint main() {\n    int t, M, N;\n    cin &gt;&gt; t;\n    while (t--) {\n        cin &gt;&gt; M &gt;&gt; N;\n        cout &lt;&lt; dfs(M, M, 0, N) &lt;&lt; endl;\n    }\n    return 0;\n}<\/code><\/pre>\n<h3>8.2 \u8bb0\u5fc6\u5316\u641c\u7d22\u6cd5<\/h3>\n<pre><code class=\"language-C++\">\n#include &lt;iostream&gt;\n#include &lt;cstring&gt;\nusing namespace std;\n\nconst int MAX = 15;\nint memo[MAX][MAX];\n\nint f(int m, int n) {\n    if (m == 0) return 1;\n    if (n == 0) return 0;\n    if (memo[m][n] != -1) return memo[m][n];\n    int res;\n    if (n &gt; m) res = f(m, m);\n    else res = f(m, n-1) + f(m - n, n);\n    return memo[m][n] = res;\n}\n\nint main() {\n    memset(memo, -1, sizeof(memo));\n    int t, M, N;\n    cin &gt;&gt; t;\n    while (t--) {\n        cin &gt;&gt; M &gt;&gt; N;\n        cout &lt;&lt; f(M, N) &lt;&lt; endl;\n    }\n    return 0;\n}<\/code><\/pre>\n<h3>8.3 \u52a8\u6001\u89c4\u5212\u8fed\u4ee3\u6cd5<\/h3>\n<pre><code class=\"language-C++\">\n#include &lt;iostream&gt;\nusing namespace std;\n\nconst int MAX = 15;\nint dp[MAX][MAX];\n\nvoid init_dp() {\n    for (int j = 0; j &lt; MAX; ++j) dp[0][j] = 1;\n    for (int i = 0; i &lt; MAX; ++i) dp[i][1] = 1;\n    for (int i = 1; i &lt; MAX; ++i) {\n        for (int j = 2; j &lt; MAX; ++j) {\n            if (j &gt; i) dp[i][j] = dp[i][i];\n            else dp[i][j] = dp[i][j-1] + dp[i-j][j];\n        }\n    }\n}\n\nint main() {\n    init_dp();\n    int t, M, N;\n    cin &gt;&gt; t;\n    while (t--) {\n        cin &gt;&gt; M &gt;&gt; N;\n        cout &lt;&lt; dp[M][N] &lt;&lt; endl;\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u95ee\u9898\u5f62\u5f0f\u5316\u5b9a\u4e49 1.1 \u9898\u76ee\u539f\u63cf\u8ff0 \u5c06 $M$ \u4e2a\u76f8\u540c\u7684\u82f9\u679c\u653e\u5165 $N$ \u4e2a\u76f8\u540c\u7684\u76d8\u5b50\u4e2d\uff0c\u5141\u8bb8\u76d8\u5b50\u4e3a\u7a7a\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-937","post","type-post","status-publish","format-standard","hentry","category-science-and-engineering"],"_links":{"self":[{"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/posts\/937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vite66.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=937"}],"version-history":[{"count":8,"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/posts\/937\/revisions"}],"predecessor-version":[{"id":950,"href":"https:\/\/vite66.cn\/index.php?rest_route=\/wp\/v2\/posts\/937\/revisions\/950"}],"wp:attachment":[{"href":"https:\/\/vite66.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vite66.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vite66.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}