{"id":38,"date":"2022-11-21T14:56:32","date_gmt":"2022-11-21T14:56:32","guid":{"rendered":"http:\/\/chenyl.one\/?p=38"},"modified":"2022-11-21T15:18:18","modified_gmt":"2022-11-21T15:18:18","slug":"%e6%b0%b4%e4%bb%99%e8%8a%b1%e6%95%b0%e8%bf%9b%e7%a8%8b%e6%8e%92%e5%ba%8f%e7%9a%84python%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/chenyl.fun\/?p=38","title":{"rendered":"\u6c34\u4ed9\u82b1\u6570,\u8fdb\u7a0b\u6392\u5e8f\u7684python\u5b9e\u73b0"},"content":{"rendered":"\n<p><em># 1 \u6c34\u4ed9\u82b1\u6570<\/em><\/p>\n\n\n\n<p>\u5982\u679c\u2014\u4e2a 3 \u4f4d\u6570\u7b49\u4e8e\u5176\u5404\u4f4d\u6570\u5b57\u7684\u7acb\u65b9\u548c\uff0c\u5219\u79f0\u8fd9\u4e2a\u6570\u4e3a\u6c34\u4ed9\u82b1\u6570\u3002<br>\u4f8b\u5982:153 = 1^3 +5^3+3^3\uff0c\u56e0\u6b64 153 \u5c31\u662f\u2014\u4e2a\u6c34<br>\u4ed9\u82b1\u6570\u8f93\u5165\u63cf\u8ff0\uff1a\u8f93\u5165\u2014\u4e2a\u6574\u6570 a \u4e0e\u2014\u4e2a\u6574\u6570 b,\u7528\u7a7a<br>\u683c\u5206\u9694\u8f93\u51fa\u63cf\u8ff0\uff1a\u8f93\u51fa a \u5230 b \u533a\u95f4\u5185\u7684\u6c34\u4ed9\u82b1\u6570\u793a\u4f8b:<br>\u8f93\u5165 100 170 \u8f93<br>\u51fa 153<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">a = int(input())\nb = int(input())\nif a &amp;lt; 100:\n    q = 100\nif b > 1000:\n    b = 1000\nfor num in range(a, b):\n    low = num % 10\n    mid = num \/\/ 10 % 10\n    high = num \/\/ 100\n    if num == low ** 3 + mid ** 3 + high ** 3:\n        print(num)<\/pre>\n\n\n\n<p><em># 2.\u8f93\u51fa\u8fdb\u7a0b<\/em><\/p>\n\n\n\n<p>\u67d0\u7cfb\u7edf\u4e2d\u6709 n \u4e2a\u8fdb\u7a0b\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u552f\u2014\u7684\u8fdb\u7a0b id (PID)\uff0c\u540c\u65f6\u6bcf\u4e2a\u8fdb\u7a0b\u6700\u591a\u8fd8\u6709\u4e00\u4e2a\u7236\u8fdb\u7a0b\uff0c \u7236\u8fdb\u7a0b id \u4e3a  (PPID)\uff0c\u548c\u4e00\u4e2a\u6216\u591a\u4e2a\u5b50\u8fdb\u7a0b\u3002\u82e5\u67d0\u8fdb\u7a0b\u6ca1\u6709\u7236\u8fdb\u7a0b\uff0c\u5219 PPID \u4e3a 0\u3002\u5f53\u67d0\u2014\u8fdb\u7a0b\u88ab\u7ec8\u6b62\u65f6\uff0c\u5176\u5b50\u8fdb \u7a0b\u4e5f\u5c06\u88ab\u7ec8\u6b62\u3002 \u73b0\u7ed9\u51fa\u8fdb\u7a0b id \u5217\u8868\u548c\u8d77\u5bf9\u5e94\u7684\u7236\u8fdb\u7a0b id \u5217\u8868\uff0c\u5f53\u8981\u7ec8\u6b62\u67d0\u2014\u8fdb\u7a0b\u65f6\uff0c\u8ba1\u7b97\u6700\u7ec8\u4f1a\u7ec8\u6b62\u54ea\u4e9b\u8fdb\u7a0b\uff0c\u5e76 \u5c06\u8981\u7ec8\u6b62\u7684 PID \u6309\u5347\u5e8f\u6392\u5217\u3002 \u8f93\u5165\u63cf\u8ff0: \u7b2c\u2014\u884c\u8f93\u5165\u4e24\u4e2a\u6574\u6570 n \u548c k\uff0cn \u8868\u793a\u5f53\u524d\u7cfb\u7edf\u4e2d\u8fd0\u884c\u7684\u8fdb\u7a0b\u6570;k \u8868\u793a\u8981\u7ec8\u6b62\u8fdb\u7a0b\u7684 PID \u7b2c\u4e8c\u884c\u8f93\u5165 n \u4e2a\u6b63\u6574\u6570\uff0c\u8868\u793a\u8fdb\u7a0b\u5217\u8868\uff0c\u6bcf\u4e2a\u6574\u6570\u8868\u793a\u8fdb\u7a0b\u7684 PID \u7b2c\u4e09\u884c\u8f93\u5165 n \u4e2a\u6b63\u6574\u6570\uff0c\u8868\u793a\u8fdb\u7a0b\u5217\u8868\u4e2d\u7684\u8fdb \u7a0b\u5bf9\u5e94\u7684\u7236\u8fdb\u7a0b PPID \u5217\u8868\u3002 \u793a\u4f8b\uff1a\u8f93 \u5165 <\/p>\n\n\n\n<p>4  5<\/p>\n\n\n\n<p>1  3  10 5<\/p>\n\n\n\n<p>3  0  5  3<\/p>\n\n\n\n<p>\u8f93\u51fa 5 10<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">n = int(input())\nk = int(input())\nkids = []\nfor i in range(n):\n    kids.append(int(input()))\nparents = []\nfor i in range(n):\n    parents.append(int(input()))\nppairs = {}\nfor i in range(n):\n    ppairs[parents[i]] = kids[i]\ntokill = []\ntmpk = k\ntokill.append(tmpk)\nwhile ppairs.get(tmpk):\n    tmpk = ppairs.get(tmpk)\n    tokill.append(tmpk)\nsortedToKill = sorted(tokill)\nprint(' '.join(str(i) for i in sortedToKill))<\/pre>\n\n\n\n<p>\u611f\u8c22\u9605\u8bfb,\u8bf7\u591a\u6307\u6559<\/p>\n","protected":false},"excerpt":{"rendered":"<p># 1 \u6c34\u4ed9\u82b1\u6570 \u5982\u679c\u2014\u4e2a 3 \u4f4d\u6570\u7b49\u4e8e\u5176\u5404\u4f4d\u6570\u5b57\u7684\u7acb\u65b9\u548c\uff0c\u5219\u79f0\u8fd9\u4e2a\u6570\u4e3a\u6c34\u4ed9\u82b1\u6570\u3002\u4f8b\u5982:153 = 1^3 + [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/posts\/38"}],"collection":[{"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chenyl.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=38"}],"version-history":[{"count":4,"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/chenyl.fun\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/chenyl.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chenyl.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chenyl.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}