{"id":776,"date":"2012-04-22T01:02:37","date_gmt":"2012-04-21T17:02:37","guid":{"rendered":"http:\/\/www.hsyyf.me\/?p=776"},"modified":"2015-10-30T16:35:33","modified_gmt":"2015-10-30T08:35:33","slug":"%e5%b9%bb%e6%96%b9%e6%9e%84%e9%80%a0%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.hsyyf.me\/?p=776","title":{"rendered":"\u5e7b\u65b9\u6784\u9020\uff08\u4e00\uff09"},"content":{"rendered":"<p>\u5728\u4e00\u4e2a\u7531\u82e5\u5e72\u4e2a\u6392\u5217\u6574\u9f50\u7684\u6570\u7ec4\u6210\u7684\u6b63\u65b9\u5f62\u4e2d\uff0c\u56fe\u4e2d\u4efb\u610f\u4e00\u6a2a\u884c\u3001\u4e00\u7eb5\u884c\u53ca\u5bf9\u89d2\u7ebf\u7684\u51e0\u4e2a\u6570\u4e4b\u548c\u90fd\u76f8\u7b49\uff0c\u5177\u6709\u8fd9\u79cd\u6027\u8d28\u7684\u56fe\u8868\uff0c\u79f0\u4e3a\u201c\u5e7b\u65b9\u201d\u3002\u6211\u56fd\u53e4\u4ee3\u79f0\u4e3a\u201c\u6cb3\u56fe\u201d\u3001\u201c\u6d1b\u4e66\u201d\uff0c\u53c8\u53eb\u201c\u7eb5\u6a2a\u56fe\u201d\u3002\u4e0b\u56fe\u4fbf\u662f\u8457\u540d\u7684\u201c\u6d1b\u4e66\u201d\u2014\u2014\u5728\u6570\u5b66\u4e0a\u53eb\u201c\u4e09\u9636\u5e7b\u65b9\u201d\uff1a<\/p>\n<p><a href=\"http:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/04\/luoshu.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-777\" title=\"\u6d1b\u4e66\" src=\"http:\/\/www.hsyyf.me\/wp-content\/uploads\/2012\/04\/luoshu.jpg\" alt=\"\" width=\"200\" height=\"196\" \/><\/a>\u5bf9\u4e8e\u4e09\u9636\u5e7b\u65b9\uff0c\u91d1\u5eb8\u5728\u300a\u5c04\u96d5\u82f1\u96c4\u4f20\u300b\u91cc\u6709\u4e00\u6bb5\u7cbe\u5f69\u7684\u63cf\u8ff0\uff0c\u5176\u4e2d\u6709\u6bb5\u53e3\u8bc0\u6717\u6717\u4e0a\u53e3\u2014\u2014\u201c\u4e8c\u56db\u4e3a\u80a9\uff0c\u516d\u516b\u4e3a\u8db3\uff0c\u5de6\u4e03\u53f3\u4e09\uff0c\u8db3\u4e5d\u5c65\u4e00\uff0c\u4e94\u5c45\u5176\u4e2d\u201d\u3002<\/p>\n<p>\u5728\u5e7b\u65b9\u4e2d\uff0c\u4e00\u5171\u6709\u4e09\u79cd\u7c7b\u578b\uff1a\u5947\u6570\u9636\u5e7b\u65b9\uff08n=2k+1\uff09\uff0c\u5355\u5076\u6570\u9636\u5e7b\u65b9\uff08n=2(2k+1)\uff09\uff0c\u53cc\u5076\u6570\u9636\u5e7b\u65b9\uff08n=4k\uff09\u3002\u5176\u4e2d\u5c24\u4ee5\u5947\u6570\u9636\u5e7b\u65b9\u6700\u4e3a\u7b80\u5355\uff0c\u5355\u5076\u6570\u9636\u6700\u4e3a\u590d\u6742\u3002\u5947\u6570\u9636\u5e7b\u65b9\u6709\u591a\u79cd\u6784\u9020\u65b9\u6cd5\uff0c\u5176\u4e2d\u6700\u8457\u540d\u7684\u8981\u6570\u201c\u9636\u68af\u6cd5\u201d\u4e86\u3002<\/p>\n<p>\u9636\u68af\u6cd5\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>1\u4f4d\u4e8e\u7b2c\u4e00\u884c\u4e2d\u95f4\uff1b<\/li>\n<li>\u6bcf\u4e00\u4e2a\u6570\u653e\u5728\u524d\u4e00\u4e2a\u6570\u7684\u53f3\u4e0a\u4e00\u683c\uff1b<\/li>\n<li>\u5982\u679c\u8fd9\u4e2a\u6570\u6240\u8981\u653e\u7684\u683c\u5df2\u7ecf\u8d85\u51fa\u4e86\u9876\u884c\u90a3\u4e48\u5c31\u628a\u5b83\u653e\u5728\u5e95\u884c\uff0c\u4ecd\u7136\u8981\u653e\u5728\u53f3\u4e00\u5217\uff1b<\/li>\n<li>\u5982\u679c\u8fd9\u4e2a\u6570\u6240\u8981\u653e\u7684\u683c\u5df2\u7ecf\u8d85\u51fa\u4e86\u6700\u53f3\u5217\u90a3\u4e48\u5c31\u628a\u5b83\u653e\u5728\u6700\u5de6\u5217\uff0c\u4ecd\u7136\u8981\u653e\u5728\u4e0a\u4e00\u884c\uff1b<\/li>\n<li>\u5982\u679c\u8fd9\u4e2a\u6570\u6240\u8981\u653e\u7684\u683c\u5df2\u7ecf\u8d85\u51fa\u4e86\u9876\u884c\u4e14\u8d85\u51fa\u4e86\u6700\u53f3\u5217\u90a3\u4e48\u5c31\u628a\u5b83\u653e\u5728\u524d\u4e00\u4e2a\u6570\u7684\u4e0b\u4e00\u884c\u540c\u4e00\u5217\u7684\u683c\u5185\uff1b<\/li>\n<li>\u5982\u679c\u8fd9\u4e2a\u6570\u6240\u8981\u653e\u7684\u683c\u5df2\u7ecf\u6709\u6570\u586b\u5165\uff0c\u5904\u7406\u65b9\u6cd5\u540c4.<\/li>\n<\/ol>\n<p>\u7ecf\u8fc7\u4ee5\u4e0a\u516d\u6b65\u6784\u9020\uff0c\u4e00\u4e2a\u9ad8\u9636\u5947\u6570\u5e7b\u65b9\u5c31\u51fa\u6765\u4e86\u3002<\/p>\n<p>\u5229\u7528python\u6784\u9020\u4e00\u4e2a\u5947\u6570\u5e7b\u65b9\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<br \/>\n<code lang=\"python\">#!\/usr\/bin\/env python3<br \/>\n#\u5947\u9636\u5e7b\u65b9\u6784\u9020\u2014\u2014\u9636\u68af\u6cd5<br \/>\nn=int(input(\"\u8bf7\u8f93\u5165\u4e00\u4e2a\u5947\u6570\uff08n<=19\uff09:\"))\nMagic=[([0]*n)for i in range(n)]\ni=0\nj=(n-1)\/\/2\nMagic[i][j]=1\nfor m in range(2,n*n+1,1):\n    i0=i\n    j0=j\n    i=(i+n-1)%n\n    j=(j+n+1)%n\n    if Magic[i][j]!=0:\n        i=(i0+n+1)%n\n        j=j0\n    if i0==0 and j0==n-1:\n        i=1\n        j=n-1\n    Magic[i][j]=m\nfor i in range(n):\n    for j in range(n):\n        print(\"%3d\"%Magic[i][j],end=' ')\n    print()\ninput(\"Press <Enter> to end\")<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e00\u4e2a\u7531\u82e5\u5e72\u4e2a\u6392\u5217\u6574\u9f50\u7684\u6570\u7ec4\u6210\u7684\u6b63\u65b9\u5f62\u4e2d\uff0c\u56fe\u4e2d\u4efb\u610f\u4e00\u6a2a\u884c\u3001\u4e00\u7eb5\u884c\u53ca\u5bf9\u89d2\u7ebf\u7684\u51e0\u4e2a\u6570\u4e4b\u548c\u90fd\u76f8\u7b49\uff0c\u5177\u6709\u8fd9\u79cd\u6027\u8d28\u7684\u56fe\u8868 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[16],"tags":[87,109],"class_list":["post-776","post","type-post","status-publish","format-standard","hentry","category-16","tag-python","tag-109"],"_links":{"self":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=776"}],"version-history":[{"count":0,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=\/wp\/v2\/posts\/776\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hsyyf.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}