1996 Canadian Computing Competition, Stage 1
Problem A: Deficient, Perfect, and Abundant
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 that 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 32500.
Sample Input
3 4 6 12
Sample Output
4 is a deficient number. 6 is a perfect number. 12 is an abundant number.
All Submissions
Best Solutions
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 28, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
In details, it is showing my output for 28 is a perfect number but 28 is a perfect number, right? Thanks.
Your code has a simple logic error. You should test your code on multiple inputs to make sure they're correct.
Do note that you won't be able to see all of your output, so your code is being tested on more than just the number 28.
Also I fixed my bug from earlier code.
So I need help with this, I think I know the problem but I don't know how to implement it.
The first line of the input will contain a number T, the number of test cases.
Each of the following T lines will contain a positive integer n, 1 < n < 32500.
For each integer n, determine whether it is deficient, perfect, or abundant.
I apologize if it's something that had already been outlined in help.
Here are the first two lines of your exception. The last line would help you more, but you should be able to figure it out with this.
Is this a known bug or did i get my algorithim wrong?