{"id":118,"date":"2025-08-07T03:52:51","date_gmt":"2025-08-07T03:52:51","guid":{"rendered":"https:\/\/www.starluo.top\/?p=118"},"modified":"2025-08-07T03:52:52","modified_gmt":"2025-08-07T03:52:52","slug":"%e9%a2%98%e8%a7%a3-noip-1998-%e6%8f%90%e9%ab%98%e7%bb%84-%e8%bd%a6%e7%ab%99","status":"publish","type":"post","link":"https:\/\/www.starluo.top\/?p=118","title":{"rendered":"\u9898\u89e3-[NOIP 1998 \u63d0\u9ad8\u7ec4] \u8f66\u7ad9"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u9898\u9762<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.luogu.com.cn\/problem\/P1011\" target=\"_blank\"  rel=\"nofollow\" >\u539f\u9898\u94fe\u63a5\u5728\u6b64\u3002<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h3>\n\n\n\n<p>\u706b\u8f66\u4ece\u59cb\u53d1\u7ad9\uff08\u79f0\u4e3a\u7b2c $1$ \u7ad9\uff09\u5f00\u51fa\uff0c\u5728\u59cb\u53d1\u7ad9\u4e0a\u8f66\u7684\u4eba\u6570\u4e3a $a$\uff0c\u7136\u540e\u5230\u8fbe\u7b2c $2$ \u7ad9\uff0c\u5728\u7b2c $2$ \u7ad9\u6709\u4eba\u4e0a\u3001\u4e0b\u8f66\uff0c\u4f46\u4e0a\u3001\u4e0b\u8f66\u7684\u4eba\u6570\u76f8\u540c\uff0c\u56e0\u6b64\u5728\u7b2c $2$ \u7ad9\u5f00\u51fa\u65f6\uff08\u5373\u5728\u5230\u8fbe\u7b2c $3$ \u7ad9\u4e4b\u524d\uff09\u8f66\u4e0a\u7684\u4eba\u6570\u4fdd\u6301\u4e3a $a$ \u4eba\u3002\u4ece\u7b2c $3$ \u7ad9\u8d77\uff08\u5305\u62ec\u7b2c $3$ \u7ad9\uff09\u4e0a\u3001\u4e0b\u8f66\u7684\u4eba\u6570\u6709\u4e00\u5b9a\u89c4\u5f8b\uff1a\u4e0a\u8f66\u7684\u4eba\u6570\u90fd\u662f\u524d\u4e24\u7ad9\u4e0a\u8f66\u4eba\u6570\u4e4b\u548c\uff0c\u800c\u4e0b\u8f66\u4eba\u6570\u7b49\u4e8e\u4e0a\u4e00\u7ad9\u4e0a\u8f66\u4eba\u6570\uff0c\u4e00\u76f4\u5230\u7ec8\u70b9\u7ad9\u7684\u524d\u4e00\u7ad9\uff08\u7b2c $n-1$ \u7ad9\uff09\uff0c\u90fd\u6ee1\u8db3\u6b64\u89c4\u5f8b\u3002\u73b0\u7ed9\u51fa\u7684\u6761\u4ef6\u662f\uff1a\u5171\u6709 $n$ \u4e2a\u8f66\u7ad9\uff0c\u59cb\u53d1\u7ad9\u4e0a\u8f66\u7684\u4eba\u6570\u4e3a $a$\uff0c\u6700\u540e\u4e00\u7ad9\u4e0b\u8f66\u7684\u4eba\u6570\u662f $m$\uff08\u5168\u90e8\u4e0b\u8f66\uff09\u3002\u8bd5\u95ee $x$ \u7ad9\u5f00\u51fa\u65f6\u8f66\u4e0a\u7684\u4eba\u6570\u662f\u591a\u5c11\uff1f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h3>\n\n\n\n<p>\u8f93\u5165\u53ea\u6709\u4e00\u884c\u56db\u4e2a\u6574\u6570\uff0c\u5206\u522b\u8868\u793a\u59cb\u53d1\u7ad9\u4e0a\u8f66\u4eba\u6570 $a$\uff0c\u8f66\u7ad9\u6570 $n$\uff0c\u7ec8\u70b9\u7ad9\u4e0b\u8f66\u4eba\u6570 $m$ \u548c\u6240\u6c42\u7684\u7ad9\u70b9\u7f16\u53f7 $x$\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h3>\n\n\n\n<p>\u8f93\u51fa\u4e00\u884c\u4e00\u4e2a\u6574\u6570\u8868\u793a\u7b54\u6848\uff1a\u4ece $x$ \u7ad9\u5f00\u51fa\u65f6\u8f66\u4e0a\u7684\u4eba\u6570\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #1<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u8f93\u5165 #1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>5 7 32 4<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u8f93\u51fa #1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>13<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bf4\u660e\/\u63d0\u793a<\/h3>\n\n\n\n<p>\u5bf9\u4e8e\u5168\u90e8\u7684\u6d4b\u8bd5\u70b9\uff0c\u4fdd\u8bc1 $1 \\leq a \\leq 20$\uff0c$1 \\leq x \\leq n \\leq 20$\uff0c$1 \\leq m \\leq 2 \\times 10^4$\u3002<\/p>\n\n\n\n<p>NOIP1998 \u63d0\u9ad8\u7ec4 \u7b2c\u4e00\u9898<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9898\u89e3<\/h2>\n\n\n\n<p>\u672c\u9898\u662f\u4e00\u9053\u6590\u6ce2\u90a3\u5951\u6570\u5217\u80cc\u666f\u7684\u6a21\u62df\u9898\uff0c\u6570\u636e\u91cf\u4e0d\u5927\uff0c\u56e0\u6b64\u8003\u8651\u6a21\u62df\u65b9\u6cd5\u89e3\u51b3\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6a21\u62df\u672c\u9898\u6837\u4f8b\u6570\u636e\u7684\u60c5\u51b5\u3002\u7531\u4e8e\u7b2c$ 2 $\u7ad9\u4e0a\u3001\u4e0b\u8f66\u4eba\u6570\u672a\u77e5\uff0c\u6211\u4eec\u8bbe\u7b2c\u4e8c\u7ad9\u4e0a\u3001\u4e0b\u8f66\u4eba\u6570\u4e3a$ y $\u4eba\u3002<\/p>\n\n\n\n<p>\u7531\u9898\u610f\uff0c\u5217\u51fa\u4e0b\u8868\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u7b2c$ n $\u7ad9<\/td><td>$1$<\/td><td>$2$<\/td><td>$3$<\/td><td>$4$<\/td><td>$5$<\/td><td>$6$<\/td><td>$7$<\/td><\/tr><tr><td>\u4ece\u8be5\u7ad9\u5f00\u51fa\u65f6\u7684\u4eba\u6570<\/td><td>$a$<\/td><td>$a$<\/td><td>$2a$<\/td><td>$2a+y$<\/td><td>$3a+2y$<\/td><td>$4a+4y$<\/td><td>$m$\u4eba\u5168\u90e8\u4e0b\u8f66<\/td><\/tr><tr><td>\u603b\u4e0a\u8f66\u6570<\/td><td>$a$<\/td><td>$y$<\/td><td>$a+y$<\/td><td>$a+2y$<\/td><td>$2a+3y$<\/td><td>$3a+5y$<\/td><td>$NaN$<\/td><\/tr><tr><td>\u603b\u4e0b\u8f66\u6570<\/td><td>$0$<\/td><td>$y$<\/td><td>$y$<\/td><td>$a+y$<\/td><td>$a+2y$<\/td><td>$2a+3y$<\/td><td>$NaN$<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5373\uff1a$\u4ece\u7b2c(n+1)\u7ad9\u5f00\u51fa\u65f6\u7684\u4eba\u6570=\u4ece\u7b2cn\u7ad9\u5f00\u51fa\u65f6\u7684\u4eba\u6570+\u603b\u4e0a\u8f66\u6570-\u603b\u4e0b\u8f66\u6570(n \\in N^*)$<\/p>\n\n\n\n<p>\u6839\u636e\u4e0a\u8868\u6a21\u62df\u53ef\u77e5\uff0c$m=4a+4y=32$\uff0c\u5176\u4e2d$a=5$\uff0c\u89e3\u5f97$y=3$\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c$\u7b2c4\u7ad9\u5f00\u51fa\u7684\u4eba\u6570=2a+y=2\u00d75+3=13$\u3002\u4e0e\u8f93\u51fa\u6837\u4f8b#1\u543b\u5408\u3002<\/p>\n\n\n\n<p>\u7efc\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u6a21\u62df\u7684\u65b9\u5f0f\u9012\u63a8\u51fa\u6240\u6709$a\u3001y$\u7684\u7cfb\u6570\uff0c\u518d\u901a\u8fc7\u89e3\u51fa$y$\uff0c\u8fdb\u800c\u5f97\u51fa\u7b54\u6848\u3002<\/p>\n\n\n\n<p>\u4e0b\u89c1\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;cstdio>\nint a,n,m,x,y,tot_ax,tot_yx;\nint tot_a&#91;3],tot_y&#91;3]; \/\/\u4ece\u7b2cn\u7ad9\u5f00\u51fa\u65f6\u7684\u4eba\u6570\uff08a\u3001y\u7684\u7cfb\u6570\uff09\nint up_a&#91;3],up_y&#91;3]; \/\/\u603b\u4e0a\u8f66\u6570\uff08a\u3001y\u7684\u7cfb\u6570\uff09\nint down_a&#91;3],down_y&#91;3]; \/\/\u603b\u4e0b\u8f66\u6570\uff08a\u3001y\u7684\u7cfb\u6570\uff09\nint main()\n{\n\tscanf(\"%d%d%d%d\",&amp;a,&amp;n,&amp;m,&amp;x);\n\t\/\/\u521d\u59cb\u5316\n\ttot_ax=1;\n\ttot_a&#91;0]=1,up_a&#91;0]=1;\n\ttot_a&#91;1]=1,up_y&#91;1]=1,down_y&#91;1]=1;\n\tfor(int i=3;i&lt;n;i++)\n\t{\n\t\t\/\/\u9012\u63a8\n\t\tup_a&#91;2]=up_a&#91;1]+up_a&#91;0];\n\t\tup_y&#91;2]=up_y&#91;1]+up_y&#91;0];\n\t\tdown_a&#91;2]=up_a&#91;1];\n\t\tdown_y&#91;2]=up_y&#91;1];\n\t\ttot_a&#91;2]=tot_a&#91;1]+up_a&#91;2]-down_a&#91;2];\n\t\ttot_y&#91;2]=tot_y&#91;1]+up_y&#91;2]-down_y&#91;2];\n\t\t\/\/\u66f4\u65b0\u9012\u63a8\u6761\u4ef6\n\t\tup_a&#91;0]=up_a&#91;1],up_a&#91;1]=up_a&#91;2];\n\t\tup_y&#91;0]=up_y&#91;1],up_y&#91;1]=up_y&#91;2];\n\t\tdown_a&#91;0]=down_a&#91;1],down_a&#91;1]=down_a&#91;2];\n\t\tdown_y&#91;0]=down_y&#91;1],down_y&#91;1]=down_y&#91;2];\n\t\ttot_a&#91;0]=tot_a&#91;1],tot_a&#91;1]=tot_a&#91;2];\n\t\ttot_y&#91;0]=tot_y&#91;1],tot_y&#91;1]=tot_y&#91;2];\n\t\t\/\/\u5b58\u50a8\u6240\u6c42\u7684\u7b2cx\u7ad9\u4eba\u6570\u7684a\u3001y\u7cfb\u6570\n\t\tif(i==x) tot_ax=tot_a&#91;2],tot_yx=tot_y&#91;2];\n\t}\n\tif(n>3) y=(m-tot_a&#91;2]*a)\/tot_y&#91;2]; \/\/\u89e3\u65b9\u7a0b\u5f97\u51fay\u7684\u503c\n\tprintf(\"%d\",a*tot_ax+y*tot_yx);\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p>\u8865\u5145\uff1a\u4e3a\u4ec0\u4e48\u521d\u59cb\u5316\u65f6$tot\\_ax=1$\uff0c\u89e3$y$\u503c\u65f6\u65f6\u8981\u52a0\u5165$if(n>3)$\u7684\u5224\u65ad\uff1f<\/p>\n\n\n\n<p>\u7b54\uff1a\u662f\u4e3a\u4e86\u7279\u5224$n=1,2$\u65f6\u7684\u7279\u6b8a\u60c5\u51b5\u3002<s>\u5426\u5219\u4f60\u4f1a\u5f97\u5230\u4e00\u4e2a\u8dd1\u51faWA\u751a\u81f3RE\u768480\u5206\u7a0b\u5e8f\u3002<\/s><\/p>\n\n\n\n<p>\u5f53\u7136\uff0c\u8be5\u9898\u89e3\u7684\u4ee3\u7801\u5e76\u4e0d\u591f\u7b80\u6d01\uff0c\u662f\u56e0\u4e3a\u52a0\u5165\u4e86\u4e00\u4e9b\u4e0e\u8ba1\u7b97\u7ed3\u679c\u65e0\u5173\u7684\u6a21\u62df\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u8981\u6539\u7b80\u6d01\u4e00\u70b9\u561b\u2026\u2026\u4e0b\u6b21\u4e00\u5b9a\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u9762 \u539f\u9898\u94fe\u63a5\u5728\u6b64\u3002 \u9898\u76ee\u63cf\u8ff0 \u706b\u8f66\u4ece\u59cb\u53d1\u7ad9\uff08\u79f0\u4e3a\u7b2c $1$ \u7ad9\uff09\u5f00\u51fa\uff0c\u5728\u59cb\u53d1\u7ad9\u4e0a\u8f66\u7684\u4eba\u6570\u4e3a $a$\uff0c\u7136\u540e\u5230\u8fbe\u7b2c $2$ \u7ad9\uff0c\u5728\u7b2c &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[8,1],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-oi","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.starluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":9,"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/www.starluo.top\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/www.starluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.starluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.starluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}