{"id":591,"date":"2024-06-20T09:00:00","date_gmt":"2024-06-20T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=591"},"modified":"2024-05-17T21:22:22","modified_gmt":"2024-05-17T13:22:22","slug":"itsa-202404-4","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/itsa-202404-4\/","title":{"rendered":"ITSA 202404 #4\uff1a\u9632\u79a6\u7cfb\u7d71\u6575\u4eba\u4f86\u8972"},"content":{"rendered":"\n\n\n<p class=\"\">\u963f\u5df4\u65af\u5361\u738b\u570b\u6709\u4e00\u5929\u906d\u53d7\u9130\u570b\u7684\u653b\u64ca\u3002\u963f\u5df4\u65af\u5361\u738b\u570b\u958b\u555f\u4e86\u9435\u7246\u9632\u7a7a\u7cfb\u7d71\uff0c\u56e0\u70ba\u8cc7\u6e90\u6709\u9650\uff0c\u8acb\u4f60\u5e6b\u5fd9\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c\u5224\u65b7\u8a72\u5982\u4f55\u6700\u6709\u6548\u9632\u79a6\u4f86\u8972\u7684\u98db\u5f48\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>\u7b2c\u4e00\u884c\u6709 1 \u500b\u6b63\u6574\u6578 N (1 \u2264 N \u2264 100\uff09\uff0c\u8868\u4e0d\u5171\u6709 N \u9846\u98db\u5f48\u4f86\u8972\u3002<br>\u63a5\u4e0b\u4f86\u6709 N \u884c\u3002\u6bcf\u884c\u8cc7\u6599\u6703\u6709 2 \u500b\u6b63\u6574\u6578 D \u548c S (1 \u2264 S \u2264 4\uff09\uff0cD \u4ee3\u8868\u6b32\u5b88\u8b77\u7684\u570b\u571f\u7bc4\u570d\u4e4b\u908a\u9577 (3 \u2264 D \u2264 9\uff09\u3002<br>\u5224\u65b7 S \u8868\u793a\u98db\u5f48\u4f86\u8972\u65b9\u5411\uff1a<br>\u5982 S = 1 \u6642\uff0c\u8868\u793a\u98db\u5f48\u5f9e\u5de6\u524d\u65b9\u4f86\uff0c\u6240\u4ee5\u4f60\u7684\u9435\u7246\u9632\u7a7a\u7cfb\u7d71\u4f48\u7f6e\u8981\u5448\u73fe\u53f3\u4e0a\u5de6\u4e0b\u3002<br>\u7576 S = 2 \u6642\uff0c\u8868\u793a\u98db\u5f48\u5f9e\u53f3\u524d\u65b9\u4f86\uff0c\u6240\u4ee5\u4f60\u7684\u9435\u7246\u9632\u5b88\u7cfb\u7d71\u4f48\u7f6e\u8981\u5448\u73fe\u5de6\u4e0a\u53f3\u4e0b\u3002<br>\u7576 S = 3 \u6642\uff0c\u8868\u793a\u98db\u5f48\u5f9e\u53f3\u908a\u4f86\uff0c\u6240\u4ee5\u4f60\u7684\u9435\u7246\u9632\u5b88\u7cfb\u7d71\u7f6e\u8981\u805a\u96c6\u5230\u53f3\u908a\u3002<br>\u7576 S = 4 \u6642\uff0c\u8868\u793a\u98db\u5f48\u5f9e\u5de6\u908a\u4f86\uff0c\u6240\u4ee5\u4f60\u7684\u9435\u7246\u9632\u5b88\u7cfb\u7d71\u5e03\u7f6e\u8981\u805a\u96c6\u5230\u5de6\u908a\u3002<\/td><td><br>\u8acb\u5370\u51fa\u570b\u571f\u8207\u9435\u7246\u9632\u5b88\u7cfb\u7d71\u7684\u4f48\u7f6e\u72c0\u6cc1\uff0c\u4ee5\uff0a\u4ee3\u8868\u9435\u7246\u9632\u7a7a\u7cfb\u7d71\uff0c\u4ee5 x \u4ee3\u8868\u570b\u58eb\u3002<br>\u6bcf\u500b\uff0a\u548c x \u4e2d\u9593\u90fd\u76f8\u9694\u4e00\u500b\u7a7a\u767d\uff0c\u6bcf\u884c\u6700\u5f8c\u5fc5\u9808\u6709\u63db\u884c\u5b57\u5143\u3002<\/td><\/tr><tr><td>2<br>3 1<br>4 3<\/td><td>x x *<br>x * x<br>* x x<br>x x x *<br>x x x *<br>x x x *<br>x x x *<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ITSA 202404 #4 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u4f7f\u7528\u5224\u65b7\u5f0f\u5224\u65b7 S \u662f\u591a\u5c11\uff0c\u5982\u679c\u662f\u659c\u8457\u8d70\u7684\u8a71\u5c31\u662f\u9810\u8a2d\u4e00\u500b\u8b8a\u6578\u70ba D-1 \u6216\u662f 0\uff0c\u6bcf\u6b21 For\u8ff4\u5708\u8dd1\u5230\u9019\u500b\u8b8a\u6578\u7684\u6642\u5019\u5c31\u8f38\u51fa\u300c*\u300d\uff0c\u4e26\u4e14\u5c07\u8b8a\u6578 -1 \u6216 +1\u3002\u5982\u679c S = 2\uff0c\u6bcf\u4e00\u884c\u53ea\u8f38\u51fa\u4e00\u6b21\u300c*\u300d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5e03\u6797\u503c\u4f86\u78ba\u8a8d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/e-tutor.itsa.org.tw\/mod\/programming\/view.php?id=69433\" target=\"_blank\" rel=\"noreferrer noopener\">ITSA 202404 #4\uff1a\u9632\u79a6\u7cfb\u7d71\u6575\u4eba\u4f86\u8972<\/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    cin &gt;&gt; N;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int D, S;\n        cin &gt;&gt; D &gt;&gt; S;\n        if (S == 1)\n        {\n            int count = D-1;\n            for (int j = 0; j&lt;D; j++)\n            {\n                for (int k = 0; k&lt;D; k++)\n                {\n                    if (k != 0) cout &lt;&lt; &quot; &quot;;\n                    if (k == count)\n                    {\n                        count--;\n                        cout &lt;&lt; &quot;*&quot;;\n                    }\n                    else cout &lt;&lt; &quot;x&quot;;\n                }\n                cout &lt;&lt; &quot;\\n&quot;;\n            }\n        }\n        else if (S == 2)\n        {\n            int count = 0;\n            for (int j = 0; j&lt;D; j++)\n            {\n                bool ok = true;\n                for (int k = 0; k&lt;D; k++)\n                {\n                    if (k != 0) cout &lt;&lt; &quot; &quot;;\n                    if (k == count && ok)\n                    {\n                        ok = false;\n                        count++;\n                        cout &lt;&lt; &quot;*&quot;;\n                    }\n                    else cout &lt;&lt; &quot;x&quot;;\n                }\n                cout &lt;&lt; &quot;\\n&quot;;\n            }\n        }\n        else if (S == 3)\n        {\n            for (int j = 0; j&lt;D; j++)\n            {\n                for (int k = 0; k&lt;D; k++)\n                {\n                    if (k != 0) cout &lt;&lt; &quot; &quot;;\n                    if (k == D-1) cout &lt;&lt; &quot;*&quot;;\n                    else cout &lt;&lt; &quot;x&quot;;\n                }\n                cout &lt;&lt; &quot;\\n&quot;;\n            }\n        }\n        else\n        {\n            for (int j = 0; j&lt;D; j++)\n            {\n                for (int k = 0; k&lt;D; k++)\n                {\n                    if (k != 0) cout &lt;&lt; &quot; &quot;;\n                    if (k == 0) cout &lt;&lt; &quot;*&quot;;\n                    else cout &lt;&lt; &quot;x&quot;;\n                }\n                cout &lt;&lt; &quot;\\n&quot;;\n            }\n        }\n    }\n}\n\n\/\/ITSA 202404 #4\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u963f\u5df4\u65af\u5361\u738b\u570b\u6709\u4e00\u5929\u906d\u53d7\u9130\u570b\u7684\u653b\u64ca\u3002\u963f\u5df4\u65af\u5361\u738b\u570b\u958b\u555f\u4e86\u9435\u7246\u9632\u7a7a\u7cfb\u7d71\uff0c\u56e0\u70ba\u8cc7\u6e90\u6709\u9650\uff0c\u8acb\u4f60\u5e6b\u5fd9\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c\u5224\u65b7\u8a72\u5982\u4f55 [&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":[36],"tags":[8,34,9],"class_list":["post-591","post","type-post","status-publish","format-standard","hentry","category-itsa","tag-8","tag-34","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/591","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=591"}],"version-history":[{"count":3,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/591\/revisions"}],"predecessor-version":[{"id":594,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/591\/revisions\/594"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}