{"id":24053,"date":"2020-02-12T00:03:16","date_gmt":"2020-02-11T16:03:16","guid":{"rendered":"http:\/\/4563.org\/?p=24053"},"modified":"2020-02-12T00:03:16","modified_gmt":"2020-02-11T16:03:16","slug":"%e5%b0%8f%e5%bc%9f%e5%8f%88%e6%9d%a5%e8%af%b7%e6%95%99python%e5%85%a5%e9%97%a8%e9%97%ae%e9%a2%98%e4%ba%86","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=24053","title":{"rendered":"\u5c0f\u5f1f\u53c8\u6765\u8bf7\u6559python\u5165\u95e8\u95ee\u9898\u4e86"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>sel<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>\u5c0f\u5f1f\u53c8\u6765\u8bf7\u6559python\u5165\u95e8\u95ee\u9898\u4e86<\/h3>\n<p>  \t\t\u5b66\u7f16\u7a0b\u7b2c\u4e94\u5929\uff0c\u73b0\u5728\u662f\u5728\u7f16\u4e00\u4e2a\u67e5\u627e\u5b8c\u7f8e\u6570\u7684\u7a0b\u5e8f\uff0c\u4f46\u662f\u4e0d\u80fd\u8fd0\u884c\uff0c\u81ea\u5df1\u7814\u7a76\u534a\u5929\u6ca1\u627e\u5230\u95ee\u9898\uff0c\u6c42\u5927\u4f6c\u5e2e\u52a9yc002t<br \/>  count = int(input())<br \/>  is_perfect = 0<br \/>  for i in range(count):<br \/>  &nbsp; &nbsp; for j in range(i\/2+1):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if i\/j == 0:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;is_perfect += j<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if is_perfect == i:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;print(&#8216;%d &#8216; % is_perfect)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;is_perfect = 0  \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u5915\u65e5<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tsel \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-11 23:40<br \/>  \u554a \u8fd8\u771f\u7684\u662f \u8c22\u8c22\u5927\u4f6c\u503c\u70b9 \u6211\u518d\u53bb\u7814\u7a76\u4e0b<\/p>\n<p> \u4e0a\u9762\u90a3\u6761\u56de\u590d\u66f4\u65b0\u4e86\u4e00\u4e0b\uff0c\u4f60\u7684\u4ee3\u7801\u8fd8\u6709\u5176\u4ed6\u95ee\u9898\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>mfcer<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\trunoob.com\/python\/python-tutorial.html\u4e07\u4e08\u9ad8\u697c\u5e73\u5730\u8d77\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u5915\u65e5<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 \u5915\u65e5 \u4e8e 2020-2-11 23:43 \u7f16\u8f91 <\/p>\n<p> range()\u63a5\u53d7\u7684\u53c2\u6570\u9700\u8981\u662f\u6574\u6570\uff0c\u4f60\u8fd9\u80fd\u4fdd\u8bc1i\/2+1\u662f\u6574\u6570\u5417\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c<br \/>  \u5e76\u4e14\u8fd9\u79cd\u4e1c\u897f\u5e94\u8be5\u6709\u62a5\u9519\u7684\u5427\uff0c\u4f60\u90fd\u4e0d\u770b\u7684\u5417\uff1f\u770b\u4e0d\u61c2\u7684\u8bdd\u968f\u4fbf\u590d\u5236\u4e00\u4e0b\u90fd\u80fd\u641c\u5230\u4e00\u5806\u6559\u7a0b\u554a\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c<br \/>  \u518d\u95ee\u51fa\u8fd9\u79cd\u95ee\u9898\u7684\u8bdd\uff0c\u6211\u53ea\u80fd\u8bf4\u4f60\u771f\u7684\u4e0d\u9002\u5408\u7f16\u7a0b\uff08\u975e\u8d2c\u4f4e\uff0c\u7eaf\u5efa\u8bae\uff0c\u56e0\u4e3a\u4f60\u8fde\u6700\u57fa\u7840\u7684\u641c\u7d22\u90fd\u505a\u4e0d\u5230\uff09yc022t<br \/>  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>  \u6b63\u597d\u6253\u5f00\u4e86vscode\uff0c\u968f\u624b\u590d\u5236\u4e86\u8dd1\u4e86\u4e00\u4e0b\uff0c\u6211\u9760\u4f60\u8fd9\u4ee3\u7801\uff0c\u65e0\u8bed\u4e86<br \/>  \u7b2c\u4e09\u884c range()\u9700\u8981\u6574\u6570\u53c2\u6570<br \/>  \u7b2c\u4e94\u884cj\u53ef\u80fd\u4e3a0\uff0c\u800c0\u4e0d\u80fd\u4f5c\u4e3a\u9664\u6570<br \/>  \u518d\u4e0b\u9762\u61d2\u5f97\u8bd5\u4e86\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>cherbim<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 cherbim \u4e8e 2020-2-12 00:14 \u7f16\u8f91 <\/p>\n<p> \u8d34\u4e2a\u9519\u8bef\u63d0\u793a\u554a<br \/>  PS\uff1ai \u548c j \u53d6\u503c\u4ece1\u5f00\u59cb\u800c\u4e0d\u662f0\uff0ci\/j\u4e0d\u5bf9\uff0c\u4e0d\u662f\u9664\u4ee5\uff0c\u662f\u6c42\u4f59 %\uff0c\u7b2c\u4e8c\u4e2aif\u7f29\u8fdb\u6709\u95ee\u9898\uff0c\u5e94\u5728\u7b2c\u4e8c\u4e2afor\u5916\uff0c\u6700\u540e\u4e00\u884c\u7f29\u8fdb\u548c\u7b2c\u4e8c\u4e2aif\u5e94\u8be5\u540c\u7b49\u5730\u4f4d\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>sel<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5915\u65e5 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-11 23:36<br \/>  range()\u63a5\u53d7\u7684\u53c2\u6570\u9700\u8981\u662f\u6574\u6570\uff0c\u4f60\u8fd9\u80fd\u4fdd\u8bc1i\/2+1\u662f\u6574\u6570\u5417\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c<br \/>  \u5e76\u4e14\u8fd9\u79cd\u4e1c\u897f\u5e94\u8be5\u6709\u62a5\u9519\u7684\u5427\uff0c\u4f60\u90fd\u4e0d &#8230;<\/p>\n<p> \u554a \u8fd8\u771f\u7684\u662fyc020t \u8c22\u8c22\u5927\u4f6c\u503c\u70b9 \u6211\u518d\u53bb\u7814\u7a76\u4e0b\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>sel<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5915\u65e5 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-11 23:42<br \/>  \u4e0a\u9762\u90a3\u6761\u56de\u590d\u66f4\u65b0\u4e86\u4e00\u4e0b\uff0c\u4f60\u7684\u4ee3\u7801\u8fd8\u6709\u5176\u4ed6\u95ee\u9898\uff0c\uff0c\uff0c\uff0c\uff0c\uff0c<\/p>\n<p> count = int(input())<br \/>  is_perfect = 0<br \/>  for i in range(count):<br \/>  &nbsp; &nbsp; for j in range(1,int(i\/2)+1):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if i%j == 0:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;is_perfect += j<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if is_perfect == i:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;print(&#8216;%d &#8216; % is_perfect)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;is_perfect = 0<br \/>  \u6211\u6539\u6210\u4e86\u8fd9\u6837 \u597d\u50cf\u8fd8\u662f\u6709\u95ee\u9898yc006t\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8fd9\u662f\u4f60\u63a5\u89e6\u7684\u7b2c\u4e00\u95e8\u8bed\u8a00\u4e48\uff1f<br \/>  \u5982\u679c\u662f\u7b2c\u4e00\u95e8\u8bed\u8a00\u7684\u8bdd \u51fa\u9519\u6b63\u5e38\uff0c \u53ea\u8981\u4f1a\u770b\u9519\u8bef\u63d0\u793a\uff0c \u5584\u7528\u641c\u7d22<br \/>  \u8fd8\u662f\u641e\u4e0d\u61c2\u518d\u53d1\u5e16\u6c42\u95ee\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>sel<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tyjsx86 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-2-11 23:49<br \/>  \u8fd9\u662f\u4f60\u63a5\u89e6\u7684\u7b2c\u4e00\u95e8\u8bed\u8a00\u4e48\uff1f<br \/>  \u5982\u679c\u662f\u7b2c\u4e00\u95e8\u8bed\u8a00\u7684\u8bdd \u51fa\u9519\u6b63\u5e38\uff0c \u53ea\u8981\u4f1a\u770b\u9519\u8bef\u63d0\u793a\uff0c \u5584\u7528\u641c\u7d22<br \/>  \u8fd8\u662f\u641e\u4e0d\u61c2\u518d &#8230;<\/p>\n<p> \u4e4b\u524d\u63a5\u89e6\u8fc7\u4e00\u70b9c\u8bed\u97f3 \u4f46\u662f\u6709\u5341\u5e74\u6ca1\u78b0\u8fc7\u4e86 \u6211\u518d\u7814\u7a76\u4e00\u4e0byc022t\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u6211\u662f\u4e00\u4e2a\u5927\u6c34\u602a<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u4eceSICP-Python\u5b66\u8d77\u5427\uff1a<br \/>  https:\/\/github.com\/keithnull\/TeachYourselfCS-CN\/blob\/master\/TeachYourselfCS-CN.md<\/p>\n<p>  \u4e0d\u77e5\u4f60\u4ece\u54ea\u91cc\u627e\u7684\u6559\u6750\u3002\u6c42\u5b8c\u7f8e\u6570\u8fd9\u79cd\u9700\u8981\u7b97\u6cd5\u7684\u7a0b\u5e8f\u5bf9\u521d\u5b66\u8005\u6765\u8bb2\u7b97\u5f88\u56f0\u96be\u5427\u3002\u521d\u5b66\u8005\u5e94\u8be5\u5148\u628a\u57fa\u672c\u6982\u5ff5\u641e\u61c2\u3002<\/p>\n<p>  \u7b80\u5355\u5410\u69fd\uff1a<br \/>  &#8211; \u77e5\u9053`\/`\u4e0e`\/\/`\u7684\u533a\u522b\u5417\uff1f<br \/>  &#8211; \u77e5\u9053`\/`\u4e0e`%`\u7684\u533a\u522b\u5417\uff1f<br \/>  &#8211; C\u98ce\u683c\u7684print\u5df2\u7ecf\u8fc7\u65f6\u4e86\uff0c\u8bf4\u660e\u8fd9\u5b66\u4e60\u6750\u6599\u4e5f\u57fa\u672c\u8fc7\u65f6\u4e86<\/p>\n<p>  \u6700\u540e\u7ed9\u4e2a\u7b54\u6848\uff1a<br \/>  &#8220;`<br \/>  n = int(input())<br \/>  sum = 0<br \/>  for i in range(2,n+1):<br \/>  &nbsp; &nbsp; for j in range(1,i):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if i%j == 0:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;sum += j<br \/>  &nbsp; &nbsp; if sum == i:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(i)<br \/>  &nbsp; &nbsp; sum = 0<br \/>  &#8220;`\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>sel \u5927\u4f6c\u6709\u8bdd\u8bf4 : \u5c0f\u5f1f\u53c8\u6765\u8bf7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/24053"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24053"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/24053\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24053"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}