{"id":11,"date":"2023-05-02T09:44:32","date_gmt":"2023-05-02T01:44:32","guid":{"rendered":"https:\/\/www.baic18.top\/blog\/?p=11"},"modified":"2023-05-02T09:44:32","modified_gmt":"2023-05-02T01:44:32","slug":"%e6%b4%9b%e8%b0%b7p1135-%e5%a5%87%e6%80%aa%e7%9a%84%e7%94%b5%e6%a2%af","status":"publish","type":"post","link":"https:\/\/www.n-bc.top\/?p=11","title":{"rendered":"\u6d1b\u8c37P1135 \u5947\u602a\u7684\u7535\u68af"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>\u9898\u76ee\u63cf\u8ff0(Description)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>\u6709\u4e00\u5929\u6211\u505a\u4e86\u4e00\u4e2a\u68a6\uff0c\u68a6\u89c1\u4e86\u4e00\u79cd\u5f88\u5947\u602a\u7684\u7535\u68af\u3002\u5927\u697c\u7684\u6bcf\u4e00\u5c42\u697c\u90fd\u53ef\u4ee5\u505c\u7535\u68af\uff0c\u800c\u4e14\u7b2ci\u5c42\u697c(1\u2264i\u2264N)\u4e0a\u6709\u4e00\u4e2a\u6570\u5b57Ki(0\u2264Ki\u2264N)\u3002\u7535\u68af\u53ea\u6709\u56db\u4e2a\u6309\u94ae\uff1a\u5f00\uff0c\u5173\uff0c\u4e0a\uff0c\u4e0b\u3002\u4e0a\u4e0b\u7684\u5c42\u6570\u7b49\u4e8e\u5f53\u524d\u697c\u5c42\u4e0a\u7684\u90a3\u4e2a\u6570\u5b57\u3002\u5f53\u7136\uff0c\u5982\u679c\u4e0d\u80fd\u6ee1\u8db3\u8981\u6c42\uff0c\u76f8\u5e94\u7684\u6309\u94ae\u5c31\u4f1a\u5931\u7075\u3002\u4f8b\u5982\uff1a3,3,1,2,5\u4ee3\u8868\u4e86Ki(K1=3,K2=3,\u2026)\uff0c\u4ece1\u697c\u5f00\u59cb\u3002\u57281\u697c\uff0c\u6309\u201c\u4e0a\u201d\u53ef\u4ee5\u52304\u697c\uff0c\u6309\u201c\u4e0b\u201d\u662f\u4e0d\u8d77\u4f5c\u7528\u7684\uff0c\u56e0\u4e3a\u6ca1\u6709\u22122\u697c\u3002\u90a3\u4e48\uff0c\u4eceA\u697c\u5230B\u697c\u81f3\u5c11\u8981\u6309\u51e0\u6b21\u6309\u94ae\u5462\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u8f93\u5165\u683c\u5f0f(Format Input)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>\u5171\u4e8c\u884c\u3002<br>\u7b2c\u4e00\u884c\u4e3a3\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u6b63\u6574\u6570\uff0c\u8868\u793aN,A,B(1\u2264N\u2264200, 1\u2264A,B\u2264N)<br>\u7b2c\u4e8c\u884c\u4e3aN\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u975e\u8d1f\u6574\u6570\uff0c\u8868\u793aKi\u3002<br>\u8f93\u51fa\u683c\u5f0f(Format Output)<br>\u4e00\u884c\uff0c\u5373\u6700\u5c11\u6309\u952e\u6b21\u6570,\u82e5\u65e0\u6cd5\u5230\u8fbe\uff0c\u5219\u8f93\u51fa\u22121\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u8f93\u5165\u6837\u4f8b(Sample Input)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>5 1 5<br>3 3 1 2 5<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u8f93\u51fa\u6837\u4f8b(Sample Output)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>3<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u89e3\u6790<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>\u8fd9\u9053\u9898\u5176\u5b9e\u4e0d\u96be\uff0c\u5c31\u662f\u4e00\u4e2a\u6df1\u641c\uff0c\u4e9b\u8bb8\u5224\u65ad\u5c31\u884c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4ee3\u7801<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;bits\/stdc++.h&gt;\nusing namespace std;\nint n,y,b,a&#91;1001];\nbool used&#91;1001];\nint ans=1e9;\nvoid dfs(int step,int last)\n{\n    if(last==b)\n    {\n        ans=min(ans,step);\n        return;\n    }\n    if(step&gt;ans)    return;\n    if(last+a&#91;last]&lt;=n&amp;&amp;used&#91;last+a&#91;last]]==0)\n    {\n        used&#91;last+a&#91;last]]=1;\n        dfs(step+1,last+a&#91;last]);\n        used&#91;last+a&#91;last]]=0;\n    }\n    if(last-a&#91;last]&gt;=1&amp;&amp;used&#91;last+a&#91;last]]==0)\n    {\n        used&#91;last-a&#91;last]]=1;\n        dfs(step+1,last-a&#91;last]);\n        used&#91;last-a&#91;last]]=0;\n    }\n } \nint main()\n{\n    cin&gt;&gt;n&gt;&gt;y&gt;&gt;b;\n    for(int i=1;i&lt;=n;i++)\n    {\n        scanf(\"%d\",&amp;a&#91;i]);\n    }\n    dfs(0,y);\n    if(ans==1e9)    cout&lt;&lt;-1;\n    else cout&lt;&lt;ans;\n    return 0;\n }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0(Description) \u6709\u4e00\u5929\u6211\u505a\u4e86\u4e00\u4e2a\u68a6\uff0c\u68a6\u89c1\u4e86\u4e00\u79cd\u5f88\u5947\u602a\u7684\u7535\u68af\u3002\u5927\u697c\u7684\u6bcf\u4e00\u5c42\u697c\u90fd\u53ef\u4ee5\u505c\u7535\u68af\uff0c\u800c\u4e14\u7b2ci\u5c42\u697c(1\u2264i\u2264N)\u4e0a\u6709\u4e00\u4e2a\u6570\u5b57Ki(0\u2264Ki\u2264N)\u3002\u7535\u68af\u53ea\u6709\u56db\u4e2a\u6309\u94ae\uff1a\u5f00\uff0c\u5173\uff0c\u4e0a\uff0c\u4e0b\u3002\u4e0a\u4e0b\u7684\u5c42\u6570\u7b49\u4e8e\u5f53\u524d\u697c\u5c42\u4e0a\u7684\u90a3\u4e2a\u6570\u5b57\u3002\u5f53\u7136\uff0c\u5982\u679c\u4e0d\u80fd\u6ee1\u8db3\u8981\u6c42\uff0c\u76f8\u5e94\u7684\u6309\u94ae\u5c31\u4f1a\u5931\u7075\u3002\u4f8b\u5982\uff1a3,3,1,2,5\u4ee3\u8868\u4e86Ki(K1=3,K2=3,\u2026)\uff0c\u4ece1\u697c\u5f00\u59cb\u3002\u57281\u697c\uff0c\u6309\u201c\u4e0a\u201d\u53ef\u4ee5\u52304\u697c\uff0c\u6309\u201c\u4e0b\u201d\u662f\u4e0d\u8d77\u4f5c\u7528\u7684\uff0c\u56e0\u4e3a\u6ca1\u6709\u22122\u697c\u3002\u90a3\u4e48\uff0c\u4eceA\u697c\u5230B\u697c\u81f3\u5c11\u8981\u6309\u51e0\u6b21\u6309\u94ae\u5462\uff1f \u8f93\u5165\u683c\u5f0f(Format Input) \u5171\u4e8c\u884c\u3002\u7b2c\u4e00\u884c\u4e3a3\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u6b63\u6574\u6570\uff0c\u8868\u793aN,A,B(1\u2264N\u2264200, 1\u2264A,B\u2264N)\u7b2c\u4e8c\u884c\u4e3aN\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u975e\u8d1f\u6574\u6570\uff0c\u8868\u793aKi\u3002\u8f93\u51fa\u683c\u5f0f(Format Output)\u4e00\u884c\uff0c\u5373\u6700\u5c11\u6309\u952e\u6b21\u6570,\u82e5\u65e0\u6cd5\u5230\u8fbe\uff0c\u5219\u8f93\u51fa\u22121\u3002 \u8f93\u5165\u6837\u4f8b(Sample Input) 5 1 53 3 1 2 5 \u8f93\u51fa\u6837\u4f8b(Sample Output) 3 \u89e3\u6790 \u8fd9\u9053\u9898\u5176\u5b9e\u4e0d\u96be\uff0c\u5c31\u662f\u4e00\u4e2a\u6df1\u641c\uff0c\u4e9b\u8bb8\u5224\u65ad\u5c31\u884c\u3002 \u4ee3\u7801<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[6,8],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-js","tag-js","tag-bcs","entry"],"_links":{"self":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":0,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}