{"id":723,"date":"2024-07-11T09:00:00","date_gmt":"2024-07-11T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=723"},"modified":"2024-06-05T17:56:09","modified_gmt":"2024-06-05T09:56:09","slug":"zerojudge-e558","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-e558\/","title":{"rendered":"ZeroJudge E558: Digit Generator"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 01583\uff0dDigit Generator<\/h4>\n\n\n\n<p class=\"\">\u5c0d\u65bc\u6b63\u6574\u6578 N\uff0cN \u7684 digit-sum \u5b9a\u7fa9\u70baN\u672c\u8eab\u53ca\u5176\u6240\u6709\u4f4d\u6578\u6578\u5b57\u7684\u7e3d\u548c\u3002<br>\u7576 M \u662f N \u7684 digit-sum \u6642\uff0c\u6211\u5011\u7a31 N \u70ba M \u7684 generator\u3002<br>\u4f8b\u5982\uff1a245 \u7684\u6578\u5b57\u7e3d\u548c\u70ba 256 (= 245 + 2 + 4 + 5)\u3002 \u56e0\u6b64\uff0c245 \u662f 256 \u7684 generator\u3002<br>\u4e0d\u904e\uff0c\u6709\u4e9b\u6578\u5b57\u6c92\u6709\u4efb\u4f55 generator\uff0c\u800c\u6709\u4e9b\u6578\u5b57\u6709\u591a\u500b generator\u3002<br>\u4f8b\u5982\uff1a216 \u7684 generator \u662f 198 \u548c 207\u3002<br>\u4f60\u5c07\u5beb\u4e00\u500b\u7a0b\u5f0f\u4f86\u67e5\u627e\u7d66\u5b9a\u6574\u6578\u7684\u6700\u5c0f generator\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><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\u7b2c\u4e00\u884c\u5305\u542b\u4e00\u500b\u6574\u6578 T\uff0cT \u4ee3\u8868\u6709\u5e7e\u7d44\u6e2c\u8cc7\u3002<br>\u6bcf\u7d44\u6e2c\u8cc7\u6709\u4e00\u500b\u6574\u6578 N (1 \u2264 N \u2264 100000)\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u7d44\u6e2c\u8cc7\uff0c\u8f38\u51fa N \u7684\u6700\u5c0f generator\u3002<br>\u5982\u679c N \u6c92\u6709\u4efb\u4f55 generator\uff0c\u5247\u8f38\u51fa\u300c0\u300d\u3002<\/td><\/tr><tr><td>3<br>216<br>121<br>2005<\/td><td>198<br>0<br>1979<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u8dd1 For\u8ff4\u5708 \u5f9e 1 \u5230 N-1 \u9010\u4e00\u5224\u65b7\uff0c\u5c07\u76ee\u524d\u8dd1\u5230\u7684\u6578\u5b57\u63db\u6210\u5b57\u4e32\u4e4b\u5f8c\u4e00\u500b\u4f4d\u6578\u4e00\u500b\u4f4d\u6578\u9032\u884c\u76f8\u52a0\u4e26\u5224\u65b7\u662f\u5426\u52a0\u8d77\u4f86\u662f N\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=e558\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge E558: Digit Generator<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int T;\n    cin &gt;&gt; T;\n    for (int i = 0; i&lt;T; i++) {\n        int N;\n        cin &gt;&gt; N;\n        bool ok = false;\n        for (int j = 1; j&lt;N; j++) {\n            string str = to_string(j);\n            int calc = j;\n            for (int k = 0; k&lt;str.length(); k++) calc += str[k]-&#39;0&#39;;\n            if (calc == N) {\n                cout &lt;&lt; j &lt;&lt; &quot;\\n&quot;;\n                ok = true;\n                break;\n            }\n        }\n        if (!ok) cout &lt;&lt; &quot;0\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge E558\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 01583\uff0dDigit Generator \u5c0d\u65bc\u6b63\u6574\u6578 N\uff0cN \u7684 digit-sum \u5b9a\u7fa9\u70baN [&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":[18],"tags":[8,11,13,12,9],"class_list":["post-723","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-11","tag-13","tag-12","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=723"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/723\/revisions"}],"predecessor-version":[{"id":735,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/723\/revisions\/735"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}