{"id":376,"date":"2012-05-17T14:59:00","date_gmt":"2012-05-17T06:59:00","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=376"},"modified":"2020-06-06T14:59:41","modified_gmt":"2020-06-06T06:59:41","slug":"%e6%a3%8b%e7%9b%98%e8%a6%86%e7%9b%96","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=376","title":{"rendered":"\u68cb\u76d8\u8986\u76d6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/\/\u68cb\u76d8\u8986\u76d6\n#include&lt;iostream>\n#include&lt;cmath>\nusing namespace std;\n\nint tile;\nint k;\nint board&#91;100]&#91;100];\n\nvoid printChessBoard(int s)\n{\n\tfor (int i = 0; i &lt; s; i++)\n\t{\n\t\tfor (int j = 0; j &lt; s; j++)\n\t\t\tcout &lt;&lt; board&#91;i]&#91;j];\n\t\tcout &lt;&lt; endl;\n\t}\n}\n\nvoid chessBoard(int tx, int ty, int dx, int dy, int size)\n{\n\tif (size == 1)\n\t\treturn;\n\tint t = tile++;\n\tint s = size \/ 2;\n\tif (dx &lt; tx + s &amp;&amp; dy &lt; ty + s) \/\/left-top\n\t{\n\t\tchessBoard(tx, ty, dx, dy, s);\n\t}\n\telse\n\t{\n\t\tboard&#91;tx + s - 1]&#91;ty + s - 1] = t;\n\t\tchessBoard(tx, ty, tx + s - 1, ty + s - 1, s);\n\t}\n\n\tif (dx >= tx + s &amp;&amp; dy &lt; ty + s) \/\/right-top\n\t{\n\t\tchessBoard(tx + s, ty, dx, dy, s);\n\t}\n\telse\n\t{\n\t\tboard&#91;tx + s]&#91;ty + s - 1] = t;\n\t\tchessBoard(tx + s, ty, tx + s, ty + s - 1, s);\n\t}\n\n\tif (dx &lt; tx + s &amp;&amp; dy >= ty + s) \/\/left-bottom\n\t{\n\t\tchessBoard(tx, ty + s, dx, dy, s);\n\t}\n\telse\n\t{\n\t\tboard&#91;tx + s - 1]&#91;ty + s] = t;\n\t\tchessBoard(tx, ty + s, tx + s - 1, ty + s, s);\n\t}\n\n\tif (dx >= tx + s &amp;&amp; dy >= ty + s) \/\/right-bottom\n\t{\n\t\tchessBoard(tx + s, ty + s, dx, dy, s);\n\t}\n\telse\n\t{\n\t\tboard&#91;tx + s]&#91;ty + s] = t;\n\t\tchessBoard(tx + s, ty + s, tx + s, ty + s, s);\n\t}\n\n}\n\nint main()\n{\n\tint x, y;\n\twhile (cin >> k >> x >> y)\n\t{\n\t\ttile = 0;\n\t\tmemset(board, 0, sizeof(board));\n\t\tchessBoard(0, 0, x, y, k);\n\t\tprintChessBoard(k);\n\t}\n\treturn 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-376","post","type-post","status-publish","format-standard","hentry","category-06-03-play-ground"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=376"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/376\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}