{"id":128,"date":"2024-04-26T13:38:47","date_gmt":"2024-04-26T05:38:47","guid":{"rendered":"https:\/\/seanxd.com\/?p=128"},"modified":"2024-04-26T13:38:49","modified_gmt":"2024-04-26T05:38:49","slug":"zerojudge-d127","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-d127\/","title":{"rendered":"ZeroJudge D127: Farm Area"},"content":{"rendered":"<p class=\"translation-block\">Assuming Mr. Z has collected materials just enough to build a fence with a length of L meters. He needs to use this fence to enclose a rectangular pasture. For ease of measurement, it is required that both the length and width of the rectangle must be integers. The problem is how to plan the length and width of the rectangle to maximize the area of the enclosed rectangular pasture.<\/p>\n\n\n\n<p class=\"translation-block\">For example, when L = 14, it's possible to enclose a pasture with a length of 6 and a width of 1, or a length of 4 and a width of 3. Of course, there might be other methods, but the second option yields the largest area, which is 12.<\/p>\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>Length<\/th><th>Width<\/th><th>Area<\/th><\/tr><\/thead><tbody><tr><td>6<\/td><td>1<\/td><td>6<\/td><\/tr><tr><td>4<\/td><td>3<\/td><td>12<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">The length, width, and area of the pasture when L = 14.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short nfd-delay-150\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td class=\"translation-block\">The input consists of several lines, each containing an even integer L.<\/td><td class=\"translation-block\">Output the maximum area S of the rectangular pasture that can be enclosed with the given L meters of fence.<\/td><\/tr><tr><td>14<\/td><td>12<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"translation-block\">You can use the following formula to solve this problem, which involves truncating decimals in the calculation. It's important to use a <strong>Long Long Int<\/strong> data type to avoid getting a <strong>WA<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d127\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D127: Farm Area<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-300\"><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(nullptr);\n    long long int N;\n    while (cin &gt;&gt; N)\n    {\n        long long int a = N\/4;\n        long long int b = N-2*a;\n        b \/= 2;\n        cout &lt;&lt; a * b &lt;&lt; endl;\n    }\n}\n\n\/\/ZeroJudge D127\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5047\u5b9aZ\u5148\u751f\u8490\u96c6\u7684\u6750\u6599\u6070\u597d\u53ef\u4ee5\u4fee\u5efa\u9577\u5ea6\u70baL\u7c73\u7684\u570d\u6b04\uff0c\u9700\u8981\u7528\u9019\u4e9b\u570d\u6b04\u570d\u8d77\u4e00\u500b\u77e9\u5f62\u7267\u5834\uff0c\u70ba\u65b9\u4fbf\u6e2c\u91cf\uff0c\u8981\u6c42\u77e9\u5f62\u7684\u9577\u548c\u5bec [&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":[15,13],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-long-long-int","tag-13"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/128","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=128"}],"version-history":[{"count":3,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/128\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}