{"id":223,"date":"2024-04-26T21:10:06","date_gmt":"2024-04-26T13:10:06","guid":{"rendered":"https:\/\/seanxd.com\/?p=223"},"modified":"2024-04-26T21:10:08","modified_gmt":"2024-04-26T13:10:08","slug":"zerojudge-i025","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-i025\/","title":{"rendered":"ZeroJudge I025: Sum of Proper Divisor"},"content":{"rendered":"<p class=\"translation-block\">A proper divisor, or proper factor, of a natural number, is a factor of a number other than 1 and the number itself. For example, the proper divisors of 6 are 1, 2, and 3.<\/p>\n\n\n\n<p class=\"translation-block\">Given a positive integer, find its <strong>sum of proper divisors<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/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>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td>The input consists of only one line containing a positive integer N (1 \u2264 N \u2264 65535).<\/td><td>Output the sum of the proper divisors of N.<\/td><\/tr><tr><td>6<\/td><td>6<\/td><\/tr><tr><td>12<\/td><td>16<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"translation-block\">Use a <strong>for loop from 1 to N - 1<\/strong> (excluding N itself). Since the number is not large, you can directly iterate through all the divisors of N and sum them up. Finally, output the sum of the divisors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=i025\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge I025: Sum of Proper Divisor<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    int ans = 0;\n    for (int i = 1; i&lt;N; i++)\n    {\n        if (N % i == 0) ans += i;\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/Z.O.J. I025\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u771f\u56e0\u6578\u662f\u6307\u4e00\u500b\u81ea\u7136\u6578\u9664\u81ea\u8eab\u4ee5\u5916\u7684\u56e0\u6578\u3002\u5982 6 \u7684\u56e0\u6578\u6709\u300c1\u30012\u30013\u30016\u300d\uff0c\u771f\u56e0\u6578\u662f\u300c1\u30012\u30013\u300d\u3002 \u7d66\u4f60\u4e00\u500b\u6b63 [&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":[8,13],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-6","tag-8","tag-13"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/223","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=223"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/223\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}