{"id":1109,"date":"2024-08-18T09:00:00","date_gmt":"2024-08-18T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1109"},"modified":"2024-07-16T19:30:48","modified_gmt":"2024-07-16T11:30:48","slug":"zerojudge-f360","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-f360\/","title":{"rendered":"ZeroJudge F360: Shady\u7684\u8907\u88fd\u54c1"},"content":{"rendered":"\n\n\n<p>\u7e3d\u5171\u6709 N \u500b slim shady\uff0c\u4f46\u53ea\u6709\u4e00\u500b\u662f real slim shady\uff0c\u5269\u4e0b\u90fd\u5728 imitating\uff0c\u8acb\u554f\u6709\u591a\u5c11\u4eba\u5728 imitating \u5462\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u8f38\u5165\u4e0d\u8d85\u904e 100 \u884c\uff0c\u6bcf\u884c\u6709\u4e00\u500b\u6574\u6578 N (2 \u2264 N \u2264 10^1000)\uff0cEOF\u7d50\u675f\u3002<\/td><td>\u8f38\u51fa\u6709\u591a\u5c11\u5728 imitating\u3002<\/td><\/tr><tr><td>2<br>10<br>100000<\/td><td>1<br>9<br>99999<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u4f7f\u7528\u5b57\u4e32\u7684\u65b9\u5f0f\u4f86\u6536\u8cc7\u6599\uff0c\u4e26\u4e14\u5ba3\u544a\u4e00\u500b\u51fd\u5f0f\u7528\u4f86\u6e1b1\u3001\u4e00\u500b\u5b57\u4e32 ans \u9810\u8a2d\u70ba &#8220;&#8221;\u3002<\/p>\n\n\n\n<p>\u5728\u51fd\u5f0f\u4e2d\uff0c\u9700\u8981\u5169\u500b\u53c3\u6578\uff0c\u5206\u5225\u70ba\u76ee\u524d\u7684\u4f4d\u7f6e position \u548c\u662f\u5426\u9700\u8981\u6e1b\u4e00\u7684\u5e03\u6797\u503c minus\u3002\u5982\u679c position == -1 \u5c31 return \u51fd\u5f0f\u3002\u5982\u679c\u76ee\u524d\u4f4d\u7f6e\u8981 -1\uff0c\u5247\u5224\u65b7\u76ee\u524d\u4f4d\u7f6e\u7684\u5b57\u5143\u662f\u5426\u70ba 0\uff0c\u5982\u679c\u662f 0 \u5c31\u8981\u547c\u53eb\u51fd\u5f0f\u4e26\u4e14\u5c07 position-1 \u7136\u5f8c minus \u8981\u662f true\uff0c\u9084\u8981\u5c07 9 += \u5230 ans \u4e2d\uff0c\u5426\u5247\u5c31\u5c07\u5b57\u5143\u63db\u6210\u6578\u5b57\u4e4b\u5f8c -1 += \u5230 ans \u4e2d\u3002\u5982\u679c minus \u70ba false\uff0c\u5247\u5c07\u76ee\u524d\u4f4d\u7f6e\u7684\u5b57\u5143 += \u5230 ans \u4e2d\u4e26\u4e14\u547c\u53eb\u51fd\u5f0f position-1 \u8ddf false\u3002<\/p>\n\n\n\n<p>\u5728\u4e3b\u7a0b\u5f0f\u7684\u6642\u5019\u8981\u547c\u53eb\u51fd\u5f0f\u4e26\u4e14\u8981\u7528\u5b57\u4e32\u7684\u9577\u5ea6-1 \u8ddf true\u3002<\/p>\n\n\n\n<p>\u8f38\u51fa\u6642\u5012\u8457\u8f38\u51fa ans\uff0c\u4e26\u4e14\u8981\u5728\u8ff4\u5708\u5916\u9762\u5ba3\u544a\u4e00\u500b\u5e03\u6797\u503c first\uff0c\u56e0\u70ba\u8981\u53bb\u6389\u524d\u9762\u7684 0\uff0c\u5982\u679c\u76ee\u524d\u5b57\u5143\u662f 0 \u4e14 first == true\uff0c\u5247\u76f4\u63a5 continue\uff0c\u5426\u5247\u5c31\u5c07 first \u8a2d\u70ba false \u4e14\u8f38\u51fa\u76ee\u524d\u5b57\u5143\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=f360\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F360: Shady\u7684\u8907\u88fd\u54c1<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nstring ans = &quot;&quot;, str;\n\nvoid minusOne(const bool minus, const int position) {\n    if (position == -1) return;\n    if (minus) {\n        if (str[position] == &#39;0&#39;) {\n            ans += &#39;9&#39;;\n            minusOne(true, position-1);\n        }\n        else {\n            const int num = int(str[position] - &#39;0&#39;);\n            ans += to_string(num-1);\n            minusOne(false, position-1);\n        }\n    }\n    else {\n        ans += str[position];\n        minusOne(false, position-1);\n    }\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    while (cin &gt;&gt; str) {\n        ans = &quot;&quot;;\n        minusOne(true, str.length()-1);\n        bool first = true;\n        for (int i = ans.length()-1; i&gt;=0; i--) {\n            if (ans[i] == &#39;0&#39;) {\n                if (first) continue;\n            }\n            first = false;\n            cout &lt;&lt; ans[i];\n        }\n        cout &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge F360\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7e3d\u5171\u6709 N \u500b slim shady\uff0c\u4f46\u53ea\u6709\u4e00\u500b\u662f real slim shady\uff0c\u5269\u4e0b\u90fd\u5728 imitatin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[6],"tags":[8,11,34,13,9],"class_list":["post-1109","post","type-post","status-publish","format-standard","hentry","category-6","tag-8","tag-11","tag-34","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=1109"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1109\/revisions"}],"predecessor-version":[{"id":1111,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1109\/revisions\/1111"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=1109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=1109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=1109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}