{"id":141,"date":"2024-04-26T14:16:35","date_gmt":"2024-04-26T06:16:35","guid":{"rendered":"https:\/\/seanxd.com\/?p=141"},"modified":"2024-04-26T14:16:38","modified_gmt":"2024-04-26T06:16:38","slug":"zerojudge-a040","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a040\/","title":{"rendered":"ZeroJudge A040: Armstrong Number"},"content":{"rendered":"\n\n\n<p class=\"\">\u6240\u8b02 Armstrong Number \u6307\u7684\u662f\u4e00\u500b <strong>N \u4f4d\u6578\u7684\u6574\u6578<\/strong>\uff0c\u5b83\u7684<strong>\u6240\u6709\u4f4d\u6578\u7684 N \u6b21\u65b9\u548c\u6070\u597d\u7b49\u65bc\u81ea\u5df1<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\"><strong>\u5982\uff1a<\/strong>1634 =\u00a01<sup>4<\/sup> + 6<sup>4 <\/sup>+ 3<sup>4<\/sup> + 4<sup>4<\/sup><\/p>\n\n\n\n<p class=\"\">\u8acb\u4f9d\u984c\u76ee\u9700\u6c42\u5728\u4e00\u5b9a\u7bc4\u570d\u5167\u627e\u51fa\u8a72<strong>\u7bc4\u570d\u5167\u7684\u6240\u6709 Armstrong Numbers<\/strong>\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>\u8f38\u5165\u5171\u4e00\u884c\u5305\u542b\u5169\u500b\u6578\u5b57 N \u548c M (N &lt; M\u3001N > 0\u3001M &lt;= 1000000)\uff0c\u4ee3\u8868<strong>\u5c0b\u627e Armstrong Number \u7684\u7bc4\u570d<\/strong>\u3002<\/td><td>\u5c07\u6240\u6709<strong>\u7bc4\u570d\u5167\u7684 Armstrong Number<\/strong> \u4f9d\u5e8f<strong>\u7531\u5c0f\u5230\u5927<\/strong>\u8f38\u51fa\uff0c\u5982\u679c<strong>\u6c92\u6709\u627e\u5230\u8acb\u8f38\u51fa \u300cnone\u300d<\/strong>\u3002<\/td><\/tr><tr><td>100  999<\/td><td>153  370  371  407<\/td><\/tr><tr><td>10  99<\/td><td>none<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u4f7f\u7528 <strong>For<\/strong> \u8ff4\u5708\u5f9e <strong>N \u8dd1\u5230 M<\/strong> \u4e00\u4e00\u6aa2\u67e5\u3002\u53ef\u4ee5\u5c07<strong>\u6578\u5b57\u8f49\u63db\u6210\u5b57\u4e32<\/strong>\u4f86\u9032\u884c\u963f\u59c6\u65af\u58ef\u6578\u7684\u5224\u65b7\u3002\u5c07\u5f97\u5230\u7684\u963f\u59c6\u65af\u58ef\u6578\u5b58\u5230\u4e00\u500b<strong>\u9663\u5217\/Vector<\/strong>\u4e2d\uff0c\u5224\u65b7\u5982\u679c <strong>Vector <\/strong>\u7684 <strong>Size <\/strong>\u70ba 0 \u5247\u8f38\u51fa none\uff0c\u53cd\u4e4b\u5247\u5c07 <strong>Vector<\/strong> \u4e2d\u7684\u8cc7\u6599\u8f38\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a040\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A040: \u963f\u59c6\u65af\u58ef\u6578<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-150\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;math.h&gt;\n#include &lt;vector&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint main() {\n  int N, M;\n  cin &gt;&gt; N &gt;&gt; M;\n  vector&lt;int&gt;num;\n  for (int i = N; i&lt;=M; i++)\n    {\n      string str = to_string(i);\n      int sum = 0;\n      int len = str.size();\n      for (int j = 0; j&lt;str.size(); j++)\n        {\n          sum += pow(str[j] - &#39;0&#39;, len);\n        }\n      if (sum == i) num.push_back(i);\n    }\n  sort(num.begin(), num.end());\n  if (num.size() == 0) cout &lt;&lt; &quot;none&quot; &lt;&lt; endl;\n  else\n  {\n    for (int i = 0; i&lt;num.size(); i++)\n      {\n        cout &lt;&lt; num[i] &lt;&lt; &quot; &quot;;\n      }\n  }\n}\n\n\/\/ZeroJudge A040\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6240\u8b02 Armstrong Number \u6307\u7684\u662f\u4e00\u500b N \u4f4d\u6578\u7684\u6574\u6578\uff0c\u5b83\u7684\u6240\u6709\u4f4d\u6578\u7684 N \u6b21\u65b9\u548c\u6070\u597d\u7b49\u65bc\u81ea\u5df1\u3002  [&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":[6],"tags":[20,11,19,13,12,9],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-6","tag-20","tag-11","tag-19","tag-13","tag-12","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/141\/revisions\/143"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}