{"id":623,"date":"2024-06-30T09:00:00","date_gmt":"2024-06-30T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=623"},"modified":"2024-06-30T09:31:24","modified_gmt":"2024-06-30T01:31:24","slug":"zerojudge-b917","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-b917\/","title":{"rendered":"ZeroJudge B917: Maximum Product"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 11059 &#8211; Maximum Product<\/h4>\n\n\n\n<p>\u7d66\u5b9a\u4e00\u7cfb\u5217\u6574\u6578 S = {S<sub>1<\/sub>\u3001S<sub>2<\/sub>\u3001&#8230;\u3001S<sub>N<\/sub>}\uff0c\u8acb\u627e\u51fa\u6700\u5927\u7684\u9023\u7e8c\u4e58\u7a4d\u3002\u5982\u679c\u627e\u4e0d\u5230\u6b63\u7684\u9023\u7e8c\u4e58\u7a4d\uff0c\u5247\u5c07 0 \u8996\u70ba\u6700\u5927\u4e58\u7a4d\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>EOF \u8f38\u5165\uff0c\u6bcf\u7b46\u6e2c\u8cc7\u7b2c\u4e00\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 N\uff0c\u7b2c\u4e8c\u884c\u6709 N \u500b\u6574\u6578\uff0c\u4ee3\u8868\u8981\u505a\u4e58\u6cd5\u7684\u6578\u5b57\u3002<\/td><td>\u8f38\u51fa\u6e2c\u8cc7\u7de8\u865f\u548c\u6700\u5927\u4e58\u7a4d\uff0c<strong>\u6bcf\u7b46\u8cc7\u6599\u4e2d\u9593\u9700\u7a7a\u4e00\u884c<\/strong>\u3002<\/td><\/tr><tr><td>3<br>2 4 -3<br>5<br>2 5 -1 2 -1<\/td><td>Case #1: The maximum product is 8.<br>Case #2: The maximum product is 20.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u8dd1\u4e00\u500b For\u8ff4\u5708\uff0c\u9019\u662f\u6bcf\u4e00\u6b21\u4e58\u7a4d\u7684\u8d77\u9ede\uff0c\u5728\u9019\u500b\u8ff4\u5708\u4e2d\u518d\u8dd1\u4e00\u500b For\u8ff4\u5708\uff0c\u5f9e\u8d77\u9ede\u5230 N-1\u3002\u5c07\u4e00\u500b\u8b8a\u6578 product \u9810\u8a2d\u70ba 1\uff0c\u6bcf\u4e00\u6b21 For\u8ff4\u5708\u90fd\u5c07\u76ee\u524d\u8dd1\u5230\u7684\u6578\u5b57\u4e58\u5230 product \u4e2d\uff0c\u4e26\u4e14\u6bcf\u4e00\u6b21\u4e58\u6cd5\u90fd\u5224\u65b7\u6700\u5927\u503c\u3002\u672c\u984c\u9700\u4f7f\u7528 Long Long Int\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=b917\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge B917: Maximum Product<\/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;\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;\n    while (cin &gt;&gt; N) {\n        vector&lt;int&gt;num;\n        long long int max = -999;\n        for (int i = 0; i&lt;N; i++) {\n            int tmp;\n            cin &gt;&gt; tmp;\n            num.push_back(tmp);\n        }\n        for (int i = 0; i&lt;N; i++) {\n            long long int product = 1;\n            for (int j = i; j&lt;N; j++) {\n                product *= num[j];\n                if (product &gt; max) max = product;\n            }\n        }\n        cout &lt;&lt; &quot;Case #&quot; &lt;&lt; count &lt;&lt; &quot;: The maximum product is &quot;;\n        if (max &lt; 0) cout &lt;&lt; 0;\n        else cout &lt;&lt; max;\n        cout &lt;&lt; &quot;.\\n\\n&quot;;\n        count++;\n    }\n}\n\n\/\/ZeroJudge B917\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 11059 &#8211; Maximum Product \u7d66\u5b9a\u4e00\u7cfb\u5217\u6574\u6578 S = {S1\u3001S2 [&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":[15,8,13,9],"class_list":["post-623","post","type-post","status-publish","format-standard","hentry","category-uva","tag-long-long-int","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/623","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=623"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":1035,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/623\/revisions\/1035"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}