{"id":449,"date":"2024-05-03T16:30:53","date_gmt":"2024-05-03T08:30:53","guid":{"rendered":"https:\/\/seanxd.com\/?p=449"},"modified":"2024-05-03T16:30:55","modified_gmt":"2024-05-03T08:30:55","slug":"zerojudge-c203","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-c203\/","title":{"rendered":"ZeroJudge C203: DPA Numbers I"},"content":{"rendered":"<h4 class=\"wp-block-heading\">UVa 13185 \u2013 DPA Numbers I<\/h4>\n\n\n\n<p class=\"\">An integer B is called a factor of another integer A (where A &gt; B) if A is divisible by B.<\/p>\n\n\n\n<p class=\"\">A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself).<\/p>\n\n\n\n<p class=\"\">For example, 6 and 28 are both perfect numbers because 6 = 1 + 2 + 3, and 28 = 1 + 2 + 4 + 7 + 14.<\/p>\n\n\n\n<p class=\"\">If a positive integer is not perfect, then it is either deficient or abundant, depending on whether the sum of its proper divisors is less than or greater than the number itself. Therefore, 9 is deficient because 1 + 3  12.<\/p>\n\n\n\n<p class=\"\">Please write a program to determine whether a given number is Perfect, Deficient, or Abundant.<\/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 first line of input contains a positive integer t, representing the number of test cases to follow. (1 &lt;= T &lt;= 500)<br>Each test case consists of a single line containing a positive integer N. (2 &lt;= N &lt;= 1000)<\/td><td>For each test case, output a single line indicating whether N is Perfect, Deficient, or Abundant.<\/td><\/tr><tr><td>10<br>5<br>6<br>16<br>18<br>21<br>28<br>29<br>30<br>40<br>43<\/td><td>deficient<br>perfect<br>deficient<br>abundant<br>deficient<br>perfect<br>deficient<br>abundant<br>abundant<br>deficient<\/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 for loop to iterate over each number as a potential divisor. If the remainder of N divided by the current number (i) is 0, then i is a divisor of N. After summing up the divisors, determine whether it is less than, equal to, or greater than N.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c203\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C203: DPA Numbers I<\/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 T;\n    cin &gt;&gt; T;\n    for (int i = 0; i&lt;T; i++)\n    {\n        int N;\n        cin &gt;&gt; N;\n        int count = 0;\n        for (int j = 1; j&lt;N; j++)\n        {\n            if (N % j == 0)\n            {\n                count += j;\n            }\n        }\n        if (count == N) cout &lt;&lt; &quot;perfect\\n&quot;;\n        else if (count &gt; N) cout &lt;&lt; &quot;abundant\\n&quot;;\n        else cout &lt;&lt; &quot;deficient\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge C203\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 13185 &#8211; DPA Numbers I \u4e00\u500b\u6574\u6578 B \u5982\u679c\u53ef\u4ee5\u88ab\u53e6\u4e00\u500b\u6574\u6578 A  [&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":[18],"tags":[8,13,9],"class_list":["post-449","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/449","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=449"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/449\/revisions"}],"predecessor-version":[{"id":450,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/449\/revisions\/450"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}