{"id":176,"date":"2026-04-01T09:06:02","date_gmt":"2026-04-01T01:06:02","guid":{"rendered":"https:\/\/www.heroking2000.com\/?p=176"},"modified":"2026-04-01T09:06:02","modified_gmt":"2026-04-01T01:06:02","slug":"%e6%95%b4%e6%95%b0%e5%88%92%e5%88%86%e9%97%ae%e9%a2%983","status":"publish","type":"post","link":"https:\/\/www.heroking2000.com\/?p=176","title":{"rendered":"\u6574\u6570\u5212\u5206\u95ee\u98983"},"content":{"rendered":"\n<p>\u6709\u4e00\u4e2a\u6574\u6570 n\uff0c\u8bf7\u5217\u51fa\u628a\u6574\u6570 n \u5212\u5206\u4e3a\u82e5\u5e72\u4e2a\u6b63\u6574\u6570\u7684\u6bcf\u4e00\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u6b63\u6574\u6570\u5fc5\u987b\u9009\u81ea\u6570\u7ec4 a\u3002\u6570\u7ec4 a \u4e2d\u53ef\u80fd\u6709\u91cd\u590d\u5143\u7d20\uff0c\u6bcf\u4e2a\u53ef\u4ee5\u9009\u62e9\u4e00\u6b21\u3002<br>\u4f8b\u5982\u5bf9 n = 6\uff0ca = {1, 1, 2, 2, 3, 4}\uff0cn = 1 + 1 + 2 + 2 \u662f\u53ef\u4ee5\u7684\uff0c\u6570\u7ec4 a \u4e2d\u6709 2 \u4e2a 1 \u548c 2 \u4e2a 2 \u53ef\u4f9b\u9009\u62e9\uff1bn = 2 + 2 + 2 \u5219\u4e0d\u6b63\u786e\uff0c\u56e0\u4e3a\u6570\u7ec4 a \u4e2d\u6ca1\u6709 3 \u4e2a 2\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u8f93\u5165\u5171 2 \u884c\uff1a<br>\u7b2c 1 \u884c\uff0c1 \u4e2a\u6b63\u6574\u6570 n\uff0ck\uff1b<br>\u7b2c 2 \u884c\uff0ck \u4e2a\u6b63\u6574\u6570\u00a0<math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><msub><mi>a<\/mi><mn>0<\/mn><\/msub><mo separator=\"true\">,<\/mo><msub><mi>a<\/mi><mn>1<\/mn><\/msub><mo separator=\"true\">,<\/mo><mo>\u22ef<\/mo><mo separator=\"true\">,<\/mo><msub><mi>a<\/mi><mrow><mi>k<\/mi><mtext>\u2212<\/mtext><mn>1<\/mn><\/mrow><\/msub><\/mrow><\/semantics><\/math>\u4e3a\u6570\u7ec4 a \u4e2d\u7684\u5143\u7d20\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u51fa\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u8f93\u51fa\u5171\u82e5\u5e72\u884c\uff1a<br>\u6bcf\u884c\u4e3a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u82e5\u5e72\u4e2a\u6b63\u6574\u6570\uff0c\u4e3a\u4e00\u79cd n \u5212\u5206\u4e3a\u82e5\u5e72\u4e2a\u6b63\u6574\u6570\u7684\u65b9\u6cd5\uff0c\u6bcf\u7ec4\u6570\u6309\u5728 a \u4e2d\u7684\u4e0b\u6807\u4ece\u5c0f\u5230\u5927\u8f93\u51fa\u3002\u82e5\u4e24\u79cd\u65b9\u6cd5\u4e2d\u524d k\u22121 \u4e2a\u6570\u5728 a \u4e2d\u7684\u4e0b\u6807\u76f8\u540c\uff0c\u5219\u7b2c k \u4e2a\u6570\u7684\u4e0b\u6807\u66f4\u5c0f\u7684\u5728\u524d\u3002\u5982\u679c\u4e24\u79cd\u65b9\u6cd5\u9009\u53d6\u7684\u6570\u5728 a \u4e2d\u7684\u4e0b\u6807\u4e0d\u5168\u76f8\u540c\uff0c\u5219\u89c6\u4e3a\u4e0d\u540c\u7684\u65b9\u6cd5\u3002<br>\u4f8b\u5982\u5bf9 n = 6\uff0ca = {1, 1, 2, 2, 3, 4}\uff0c\u9009\u53d6 a \u7684 0,2,4 \u6216 0,3,4 \u53f7\u5143\u7d20\u90fd\u4f1a\u5f97\u5230 n = 1 + 2 + 3\uff0c\u4e24\u8005\u90fd\u8981\u5728\u5408\u9002\u7684\u4f4d\u7f6e\u5206\u522b\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#1\u3011<\/p>\n\n\n\n<p>\u8f93\u5165#1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">6 6\n1 1 2 2 3 4<\/pre>\n\n\n\n<p>\u8f93\u51fa#1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1 1 2 2\n1 1 4\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n2 4\n2 4<\/pre>\n\n\n\n<p>\u3010\u6570\u636e\u8303\u56f4\u3011<\/p>\n\n\n\n<p><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mn>1<\/mn><mo>\u2264<\/mo><mi>n<\/mi><mo separator=\"true\">,<\/mo><msub><mi>a<\/mi><mn>0<\/mn><\/msub><mo separator=\"true\">,<\/mo><msub><mi>a<\/mi><mn>1<\/mn><\/msub><mo separator=\"true\">,<\/mo><mo>\u22ef<\/mo><mo separator=\"true\">,<\/mo><msub><mi>a<\/mi><mrow><mi>k<\/mi><mtext>\u2212<\/mtext><mn>1<\/mn><\/mrow><\/msub><mo>\u2264<\/mo><mn>1<\/mn><msup><mn>0<\/mn><mn>9<\/mn><\/msup><mo separator=\"true\">;<\/mo><mn>1<\/mn><mo>\u2264<\/mo><mi>k<\/mi><mo>\u2264<\/mo><mn>20<\/mn><mtext>\u3002<\/mtext><\/mrow><\/semantics><\/math><\/p>\n\n\n\n<p>\u3010\u4ee3\u7801\u793a\u4f8b\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h>\nusing namespace std;\nint n, k, a&#91;25], b&#91;25];\n\nvoid dfs(int step, int last, int sum) {\n\tif (step > n || last > n || sum >= k) {\n\t\tif (sum == k) {\n\t\t\tfor (int i = 1; i &lt; step; i++)\n\t\t\t\tcout &lt;&lt; a&#91;b&#91;i]] &lt;&lt; ' ';\n\t\t\tcout &lt;&lt; endl;\n\t\t\treturn;\n\t\t} else {\n\t\t\treturn ;\n\t\t}\n\n\t}\n\tfor (int i = last; i &lt;= n; i++) {\n\t\tb&#91;step] = i;\n\t\tdfs(step + 1, i + 1, sum + a&#91;i]);\n\t}\n}\n\nint main() {\n\tcin >> n >> k;\n\tfor (int i = 1; i &lt;= n; i++)\n\t\tcin >> a&#91;i];\n\tdfs(1, 1, 0);\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e00\u4e2a\u6574\u6570 n\uff0c\u8bf7\u5217\u51fa\u628a\u6574\u6570 n \u5212\u5206\u4e3a\u82e5\u5e72\u4e2a\u6b63\u6574\u6570\u7684\u6bcf\u4e00\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u6b63\u6574\u6570\u5fc5\u987b\u9009\u81ea\u6570\u7ec4 a\u3002\u6570\u7ec4 a \u4e2d\u53ef\u80fd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[35,25],"class_list":["post-176","post","type-post","status-publish","format-standard","hentry","category-oi","tag-dfs","tag-25"],"_links":{"self":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176"}],"version-history":[{"count":1,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":177,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions\/177"}],"wp:attachment":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}