{"id":737,"date":"2024-07-14T09:00:00","date_gmt":"2024-07-14T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=737"},"modified":"2024-06-05T20:03:51","modified_gmt":"2024-06-05T12:03:51","slug":"zerojudge-n803","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-n803\/","title":{"rendered":"ZeroJudge N803: The Coco-Cola Store"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 11877 &#8211; The Coco-Cola Store<\/h4>\n\n\n\n<p class=\"\">\u5f9e\u524d\uff0c\u6709\u4e00\u5bb6\u7279\u5225\u7684\u53ef\u53e3\u53ef\u6a02\u5546\u5e97\u3002<strong>\u5982\u679c\u4f60\u628a\u4e09\u500b\u7a7a\u74f6\u5b50\u9000\u9084\u7d66\u5546\u5e97\uff0c\u4f60\u5c07\u5f97\u5230\u4e00\u74f6\u6eff\u6eff\u7684\u53ef\u53e3\u53ef\u6a02\u53ef\u4ee5\u559d<\/strong>\u3002\u5982\u679c\u4f60\u624b\u4e0a\u6709 N \u500b\u7a7a\u74f6\u5b50\uff0c\u4f60\u6700\u591a\u53ef\u4ee5\u559d\u5230\u591a\u5c11\u74f6\u53ef\u53e3\u53ef\u6a02\uff1f<\/p>\n\n\n\n<p class=\"\">\u63d0\u793a\uff1a \u8b93\u6211\u544a\u8a34\u4f60\u5982\u4f55\u7528 10 \u500b\u7a7a\u74f6\u559d\u5230 5 \u74f6\u6eff\u74f6\u53ef\u53e3\u53ef\u6a02\uff1a\u7528 9 \u500b\u7a7a\u74f6\u63db\u53d6 3 \u74f6\u6eff\u74f6\uff0c\u559d\u6389\u5b83\u5011\u5f97\u5230 3 \u500b\u7a7a\u74f6\uff0c\u7136\u5f8c\u518d\u6b21\u7528\u9019\u4e9b\u7a7a\u74f6\u63db\u53d6\u4e00\u74f6\u6eff\u74f6\u3002\u73fe\u5728\u4f60<strong>\u6709 2 \u500b\u7a7a\u74f6\uff0c\u5411\u5e97\u88e1\u501f\u4e00\u500b\u7a7a\u74f6\uff0c\u518d\u63db\u53d6\u4e00\u74f6\u6eff\u74f6\u3002\u559d\u6389\u5b83\uff0c\u6700\u5f8c\u5c07\u9019\u500b\u7a7a\u74f6\u9084\u7d66\u5e97\u88e1\u3002<\/strong><\/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><strong>EOF \u8f38\u5165<\/strong>\uff0c\u6bcf\u500b\u6848\u4f8b\u5305\u542b\u4e00\u884c\u6574\u6578 N (1 \u2264 N \u2264 100)\u3002\u8f38\u5165\u4ee5 N = 0 \u7d50\u675f\uff0c\u6b64\u6578\u503c\u4e0d\u9700\u8655\u7406\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u500b\u6e2c\u8a66\u6848\u4f8b\uff0c\u8f38\u51fa\u4f60\u53ef\u4ee5\u559d\u5230\u7684\u6eff\u74f6\u53ef\u53e3\u53ef\u6a02\u7684\u6578\u91cf\u3002<\/td><\/tr><tr><td>3<br>10<br>81<br>0<\/td><td>1<br>5<br>40<\/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=\"\">\u4f7f\u7528 While (N >= 3)\uff0c\u88e1\u9762\u5148\u5ba3\u544a\u4e00\u500b\u8b8a\u6578 bottle \u4ee3\u8868\u53ef\u4ee5\u559d\u591a\u5c11\u53ef\u6a02\uff0c\u4e5f\u5c31\u662f N\/3\u3002\u4e4b\u5f8c\u5c07\u7b54\u6848 += bottle\u3001N -= bottle*3\u3001N += bottle\u3002<\/p>\n\n\n\n<p class=\"\">\u56e0\u70ba\u53ef\u4ee5\u8ddf\u5e97\u5bb6\u501f\u7a7a\u74f6\u5b50\uff0c\u6240\u4ee5\u5728 While\u8ff4\u5708 \u5916\u9762\u8981\u65b0\u589e\u4e00\u500b\u5224\u65b7\u5f0f\uff0c\u5982\u679c While\u8ff4\u5708 \u7d50\u675f\u4e4b\u5f8c N == 2\uff0c\u4ee3\u8868\u53ef\u4ee5\u501f\u74f6\u5b50\uff0c\u7b54\u6848++\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=n803\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge N803: The Coco-Cola Store<\/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 N;\n    while (cin &gt;&gt; N && N != 0) {\n        int ans = 0;\n        while (N &gt;= 3) {\n            int bottle = N\/3;\n            ans += bottle;\n            N -= bottle*3;\n            N += bottle;\n        }\n        if (N == 2) ans++;\n        cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge N803\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 11877 &#8211; The Coco-Cola Store \u5f9e\u524d\uff0c\u6709\u4e00\u5bb6\u7279\u5225\u7684\u53ef\u53e3\u53ef\u6a02\u5546 [&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,13,9],"class_list":["post-737","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/737","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=737"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/737\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/737\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}