{"id":156,"date":"2021-10-10T20:39:32","date_gmt":"2021-10-10T12:39:32","guid":{"rendered":"https:\/\/mzdyl.xyz\/?p=156"},"modified":"2021-10-10T20:39:33","modified_gmt":"2021-10-10T12:39:33","slug":"p1980-%e8%ae%a1%e6%95%b0%e9%97%ae%e9%a2%98-%ef%bc%88%e4%be%9d%e6%97%a7%e6%9c%aa%e5%ae%8c%e5%be%85%e7%bb%ad%ef%bc%89","status":"publish","type":"post","link":"https:\/\/mzdyl.xyz\/index.php\/2021\/10\/10\/p1980-%e8%ae%a1%e6%95%b0%e9%97%ae%e9%a2%98-%ef%bc%88%e4%be%9d%e6%97%a7%e6%9c%aa%e5%ae%8c%e5%be%85%e7%bb%ad%ef%bc%89\/","title":{"rendered":"P1980  \u8ba1\u6570\u95ee\u9898 \uff08\u4f9d\u65e7\u672a\u5b8c\u5f85\u7eed\uff09"},"content":{"rendered":"\n<p> \u600e\u4e48\u8bf4\u5462\uff0c\u8fd9\u9898\u786e\u5b9e\u662f\u4e2a\u5165\u95e8\u9898\uff0c\u4f46\u5728\u975e\u6bd4\u8d5b\u7684\u6761\u4ef6\u4e0b\u53ef\u4ee5\u4f18\u5316\u4e00\u4e0b\u8fc7\u7a0b<\/p>\n\n\n\n<p>\u7136\u540e\u6211\u5361\u4e86\u3002\u3002\u3002<\/p>\n\n\n\n<p>\u5148\u653e\u4e00\u4e0b\u5927\u4f6c\u7684\u601d\u8def<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.luogu.com.cn\/user\/14888\" target=\"_blank\"><strong>John_Nash<\/strong><\/a><\/p><cite>\u8fd9\u9898\u662fnoip2013\u666e\u53ca\u7ec4\u7b2c\u4e00\u9898\uff0c\u96be\u5ea6\u80af\u5b9a\u4e0d\u5927\uff0cnlog10n\u7684\u7b97\u6cd5\u4e0d\u96be\u60f3\u51fa\uff0c\u8fd9\u91cc\u4e0d\u518d\u8bf4\u660e\u3002<br>\u5728\u771f\u6b63\u7684\u6bd4\u8d5b\u4e2d\uff0c\u53ea\u8981\u60f3\u5230\u80fdac\u7684\u7b97\u6cd5\u5c31\u53ef\u4ee5\uff0c\u4f46\u662f\u5728\u7ec3\u4e60\u4e2d\u8fd8\u662f\u8981\u953b\u70bc\u81ea\u5df1\u7684\u601d\u7ef4\uff0c\u591a\u60f3\u60f3\u66f4\u4f18\u7684\u7b97\u6cd5\u3002<br>\u4e0d\u96be\u53d1\u73b0\uff0c\u5373\u4f7f\u4e0d\u7528\u8ba1\u7b97\u673a\uff0c\u7b54\u6848\u4e5f\u5f88\u5bb9\u6613\u6c42\u51fa\uff0c\u5982\uff1an=728\uff0cx=7<br>\u53ef\u4ee5\u6309\u7167\u8fd9\u6837\u7684\u601d\u8def\uff1a<br>\u4e2a\u4f4d7:73\u4e2a 7,17,&#8230;,727<br>\u5341\u4f4d7:70\u4e2a 70~79,170~179,&#8230;,670~679<br>\u767e\u4f4d7:29\u4e2a 700~728<br>\u7b54\u6848\u662f172<br>\u8fd9\u6837\uff0c\u5c31\u4e0d\u96be\u5199\u51falog10n\u7684\u7b97\u6cd5\uff0c\u8fd9\u662f\u4e00\u4e2a\u5de8\u5927\u7684\u6539\u8fdb\uff01<\/cite><\/blockquote>\n\n\n\n<p>\u5927\u4f6c\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n#include&lt;iostream>\n#include&lt;cstdio>\nusing namespace std;\nint main(){\n    int n,x,m=1,ans=0;\n    scanf(\"%d%d\",&amp;n,&amp;x);\n    while(m&lt;=n){\n        int a=n\/(m*10),b=n\/m%10,c=n%m; \/\/a,b,c\u4e3an\u7684\u4e09\u90e8\u5206\uff0c\u6c42\u54ea\u4e00\u4f4dx\u7684\u4e2a\u6570\uff0cb\u5c31\u4e3a\u90a3\u4e00\u4f4d\u6570\uff0ca\u4e3ab\u5de6\u8fb9\u7684\u6570\uff0cc\u4e3ab\u53f3\u8fb9\u7684\u6570\uff0c\u5982\u6c421~728\u4e2d\u5341\u4f4d7\u7684\u4e2a\u6570\uff0c\u5219a=7\uff0cb=2\uff0cc=8\n        if(x){\n            if(b>x) ans+=(a+1)*m; \/\/\u5982\u679cb>x\uff0c\u8bf4\u660e\u6709(a+1)*m\u4e2ax\uff08\u5982\u6c421~728\u4e2d\u4e2a\u4f4d7\u7684\u4e2a\u6570\uff0c\u5219\u4e3a\uff0872+1\uff09*1=73\uff09\n            if(b==x) ans+=a*m+c+1; \/\/\u5982\u679cb=x\uff0c\u8bf4\u660e\u6709a*m+c+1\u4e2ax\uff08\u5982\u6c421~728\u4e2d\u767e\u4f4d7\u7684\u4e2a\u6570\uff0c\u5219\u4e3a0*100+28+1=29\uff09\n            if(b&lt;x) ans+=a*m; \/\/\u5982\u679cb&lt;x\uff0c\u8bf4\u660e\u6709a*m\u4e2ax\uff08\u5982\u6c421~728\u4e2d\u5341\u4f4d7\u7684\u4e2a\u6570\uff0c\u5219\u4e3a7*10\u4e2a\uff09\n        }\n        else{ \/\/x=0\u7684\u60c5\u51b5\u548cx\uff01=0\u7684\u60c5\u51b5\u6709\u6240\u4e0d\u540c\n            if(b) ans+=a*m;\n            else ans+=(a-1)*m+c+1;\n        }\n        m*=10;\n    }\n    printf(\"%d\\n\",ans);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u6211\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;bits\/stdc++.h>\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n    int n,x;\r\n    cin >> n >>x;\r\n    int a,b,c;\/\/\u5b9a\u4e49a\uff0cb\uff0cc\u5206\u522b\u8bbe\u5b9a\u4f4d\u524d\u9762\u7684\u6570\uff0c\u8bbe\u5b9a\u4f4d\uff0c\u8bbe\u5b9a\u4f4d\u540e\u9762\u7684\u6570\r\n    int m=1;\/\/\u5b9a\u4e49m\u4e3a\u6570\u91cf\u7ea7\r\n    int num=0;\r\n    while(m&lt;=n)\/\/\u82e5m\u7684\u91cf\u7ea7\u5c0f\u4e8e\u8f93\u5165\u6570\r\n    {\r\n        a = n\/(10*m);\r\n        b = n\/m % 10;\/\/\u521d\u59cb\u7684b\u4e3a\u4e2a\u4f4d\r\n        c = n % m;\r\n\r\n\/\/        cout &lt;&lt; \"a \" &lt;&lt; a &lt;&lt; \" b \" &lt;&lt; b &lt;&lt; \" c \" &lt;&lt; c;\r\n        if(x)\/\/x\u4e0d\u4e3a0\uff08x\u4e3a0\u5355\u72ec\u8ba8\u8bba\uff09\r\n        {\r\n            if(b>x) num +=(a+1)*m;\r\n            else if(b==x) num +=a*m+c+1;\r\n            else num +=a*m;\r\n        }\r\n        else\r\n        {\r\n            if(b) num +=a*m;\r\n            else num +=(a-1)*m+c+1;\r\n        }\r\n        m*=10;\r\n    }\r\n    cout &lt;&lt; num;\r\n}<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u6211\u60f3\u4e86\u51e0\u5929\u4f9d\u65e7\u6709\u4e00\u70b9\u8ff7\u7cca\uff0c\u6240\u4ee5\u6682\u4e14\u8bb0\u5f55\u4e0b\u6765\uff0c\u7559\u7a7a\u518d\u6b21\u5206\u6790<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u600e\u4e48\u8bf4\u5462\uff0c\u8fd9\u9898\u786e\u5b9e\u662f\u4e2a\u5165\u95e8\u9898\uff0c\u4f46\u5728\u975e\u6bd4\u8d5b\u7684\u6761\u4ef6\u4e0b\u53ef\u4ee5\u4f18\u5316\u4e00\u4e0b\u8fc7\u7a0b \u7136\u540e\u6211\u5361\u4e86\u3002\u3002\u3002 \u5148\u653e\u4e00\u4e0b\u5927\u4f6c\u7684\u601d\u8def Joh [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-continued"],"_links":{"self":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":1,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/156\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}