{"id":944,"date":"2024-07-25T09:00:00","date_gmt":"2024-07-25T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=944"},"modified":"2024-06-25T17:59:44","modified_gmt":"2024-06-25T09:59:44","slug":"zerojudge-c164","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-c164\/","title":{"rendered":"ZeroJudge C164: Golden Coins"},"content":{"rendered":"\n\n\n<p>\u570b\u738b\u5c07\u91d1\u5e63\u4f5c\u70ba\u5de5\u8cc7\uff0c\u767c\u653e\u7d66\u5fe0\u8aa0\u7684\u9a0e\u58eb\u3002\u7b2c\u4e00\u5929\uff0c\u9a0e\u58eb\u6536\u5230\u4e00\u679a\u91d1\u5e63\uff1b\u4e4b\u5f8c\u5169\u5929 (\u7b2c\u4e8c\u5929\u548c\u7b2c\u4e09\u5929\uff09\uff0c\u6bcf\u5929\u6536\u5230\u5169\u679a\u91d1\u5e63\uff1b\u4e4b\u5f8c\u4e09\u5929 (\u7b2c\u56db\u3001\u4e94\u3001\u516d\u5929\uff09\uff0c\u6bcf\u5929\u6536\u5230\u4e09\u679a\u91d1\u5e63\uff1b\u4e4b\u5f8c\u56db\u5929\uff08\u7b2c\u4e03\u3001\u516b\u3001\u4e5d\u3001\u5341\u5929\uff09\uff0c\u6bcf\u5929\u6536\u5230\u56db\u679a\u91d1\u5e63 \u2026\u2026\uff1b\u9019\u7a2e\u5de5\u8cc7\u767c\u653e\u6a21\u5f0f\u6703\u4e00\u76f4\u9019\u6a23\u5ef6\u7e8c\u4e0b\u53bb\uff1a\u7576\u9023\u7e8c N \u5929\u6bcf\u5929\u6536\u5230 N \u679a\u91d1\u5e63\u5f8c\uff0c\u9a0e\u58eb\u6703\u5728\u4e4b\u5f8c\u7684\u9023\u7e8c N+1 \u5929\u88e1\uff0c\u6bcf\u5929\u6536\u5230 N+1 \u679a\u91d1\u5e63\u3002<\/p>\n\n\n\n<p>\u8acb\u8a08\u7b97\u5728\u524d K \u5929\u88e1\uff0c\u9a0e\u58eb\u4e00\u5171\u7372\u5f97\u4e86\u591a\u5c11\u91d1\u5e63\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\"><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\u6587\u4ef6\u53ea\u67091\u884c\uff0c\u5305\u542b\u4e00\u500b\u6b63\u6574\u6578 K\uff0c\u8868\u793a\u767c\u653e\u91d1\u5e63\u7684\u5929\u6578\u3002<\/td><td>\u8f38\u51fa\u6587\u4ef6\u53ea\u6709 1 \u884c\uff0c\u5305\u542b\u4e00\u500b\u6b63\u6574\u6578\uff0c\u5373\u9a0e\u58eb\u6536\u5230\u7684\u91d1\u5e63\u6578\u3002<\/td><\/tr><tr><td>6<\/td><td>14<\/td><\/tr><tr><td>1000<\/td><td>29820<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u53ef\u4ee5\u5148\u5c07\u6bcf\u4e00\u5929\u6703\u767c\u653e\u7684\u91d1\u5e63\u6578\u91cf\u7d00\u9304\u8d77\u4f86\u3002\u8dd1\u4e00\u500b For\u8ff4\u5708 \u5f9e 0 \u5230 1000000\uff0c\u5728\u8ff4\u5708\u5916\u9762\u5ba3\u544a\u4e00\u500b count \u8b8a\u6578\u9810\u8a2d\u70ba 1\uff0c\u4ee3\u8868\u767c\u653e\u7684\u91d1\u5e63\u6578\u91cf\u3002\u5728\u8ff4\u5708\u4e2d\u518d\u8dd1\u4e00\u500b For\u8ff4\u5708 \u5f9e 0 \u5230 count &#8211; 1\uff0c\u4e26\u5c07 count \u9032\u884c Push_Back \u81f3\u4e00\u500b Vector \u4e2d\u3002Push_Back \u7684\u8ff4\u5708\u7d50\u675f\u5f8c\u8981\u5c07\u6700\u5916\u5c64\u7684 For\u8ff4\u5708\u7684 i += count\uff0c\u4e26\u4e14\u5c07 count++\u3002<\/p>\n\n\n\n<p>\u8dd1\u4e00\u500b For\u8ff4\u5708 \u5f9e 0 \u5230 K-1\uff0c\u4e26\u4e14\u5ba3\u544a\u4e00\u500b ans \u8b8a\u6578\u9810\u8a2d\u70ba 0\uff0c\u6bcf\u4e00\u6b21\u9032\u8ff4\u5708\u90fd\u5c07 ans += \u525b\u525b\u5ba3\u544a\u7684 Vector \u7684\u7b2c i \u500b\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c164\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C164: \u91d1\u5e63<\/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;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, count = 1, ans = 0;\n    cin &gt;&gt; N;\n    vector&lt;int&gt;num;\n    for (int i = 0; i&lt;1000000; i++) {\n        for (int j = 0; j&lt;count; j++) num.push_back(count);\n        i += count;\n        count++;\n    }\n    for (int i = 0; i&lt;N; i++) ans += num[i];\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge C164\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u570b\u738b\u5c07\u91d1\u5e63\u4f5c\u70ba\u5de5\u8cc7\uff0c\u767c\u653e\u7d66\u5fe0\u8aa0\u7684\u9a0e\u58eb\u3002\u7b2c\u4e00\u5929\uff0c\u9a0e\u58eb\u6536\u5230\u4e00\u679a\u91d1\u5e63\uff1b\u4e4b\u5f8c\u5169\u5929 (\u7b2c\u4e8c\u5929\u548c\u7b2c\u4e09\u5929\uff09\uff0c\u6bcf\u5929\u6536\u5230\u5169\u679a\u91d1\u5e63 [&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":[25],"tags":[20,8,9],"class_list":["post-944","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-20","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/944","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=944"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/944\/revisions"}],"predecessor-version":[{"id":996,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/944\/revisions\/996"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}