CCC '96 S1 - Deficient, Perfect, and Abundant

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type

Write a program that repeatedly reads a positive integer, determines if the integer is deficient, perfect, or abundant, and outputs the number along with its classification.

A positive integer, n, is said to be perfect if the sum of its proper divisors equals the number itself. (Proper divisors include 1 but not the number itself.) If this sum is less than n, the number is deficient, and if the sum is greater than n, the number is abundant.

The input starts with the number of integers that follow. For each of the following integers, your program should output the classification, as given below. You may assume that the input integers are greater than 1 and less than 32\,500.

Sample Input


Sample Output

4 is a deficient number.
6 is a perfect number.
12 is an abundant number.

CCC problem statements in large part from the PEG OJ


  • -1
    nicholaskidston  commented on Oct. 21, 2021, 2:30 p.m.


  • -1
    ayay9  commented on May 26, 2021, 12:58 p.m.

    THinking of Generating all combos but then i think it'll TLE

  • 7
    QWERTYL  commented on Dec. 13, 2020, 6:35 p.m.

    It took me a long time to realize I was outputting "a abundant" instead of "an abundant"

    • -1
      myl  commented on Feb. 20, 2021, 7:48 p.m.

      Same mistake here too

    • -1
      Dav_Did  commented on Feb. 16, 2021, 2:56 p.m.

      Thanks, that help me out because I fall for it too

  • 0
    Nate  commented on Oct. 29, 2020, 11:22 a.m.

    I have a strange comment, kind of related to the question, how many perfect integers are there up until say up until 2,147,483,647? I wrote a program, but in about 15 minutes it only got 4. And those where 6, 28, 496, and 8128. Has anybody else been able to actually get a complete list?

    • 9
      d  commented on Oct. 29, 2020, 2:02 p.m.

      A quick search found a good answer to your question. In case you're too lazy to read the link, I can summarize:

      • If 2^p-1 is prime, then 2^{p-1} (2^p-1) is a perfect number. The first few values of p are 2, 3, 5, 7, 13 and their corresponding values are 6, 28, 496, 8128, 33550336, ...
      • All other even numbers are not perfect.

      The current limitations are:

      • Right now, there are 51 known values of p (the largest is 82589933) and 51 known perfect numbers. We don't know if there are finitely or infinitely many p.
      • It is unknown if any odd numbers are perfect. An odd perfect number must be greater than 10^{1500}.

    • 1
      feliser  commented on Oct. 29, 2020, 1:40 p.m.

  • 6
    CountT  commented on Sept. 10, 2020, 5:00 p.m.

    Forgot that you have to use an instead of a before another word that starts with a vowel. FP -> Facepalm

  • -1
    chessdongdong  commented on Feb. 1, 2020, 11:11 a.m.

    Forgot the period, whoops

  • -3
    SeanJxie  commented on Nov. 11, 2019, 12:49 p.m.

    My code acts differently when running in the judge?

  • -6
    Narcariel  commented on Oct. 23, 2019, 8:48 p.m. edited

    This comment is hidden due to too much negative feedback. Click here to view it.

    • 1
      Dingledooper  commented on Oct. 23, 2019, 9:34 p.m.

      In your for-loop, is there a reason you are looping up until num/2+2? It doesn't seem intuitive why you need to add 2.

  • -23
    WEAVER  commented on Feb. 11, 2019, 6:53 p.m. edited

    This comment is hidden due to too much negative feedback. Click here to view it.

    • 4
      Arihan10  commented on Feb. 13, 2019, 9:34 a.m. edit 2

      What do you not understand? Perhaps your comment could be better phrased simply stating your problem.

  • -9
    rsylshzxdkh  commented on June 21, 2017, 4:22 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.

    • 3
      DKLS2  commented on June 21, 2017, 7:55 p.m.

      Because it is not clear, I am going to assume you are asking a question.

      Yes, the question says the sum does not include the number itself as every number would be abundant (for numbers larger than 1).