This page is still under construction.

Parts of this page are still being built. What you see may change.

Perfection

Time limit1sMemory limit128 MB

Summary
For each number below 60000, sum its proper divisors and classify it as perfect, deficient, or abundant.
Level

Easy2 of 10

Topics
Math, Number theory, Brute force
Solved
No attempts yet

Problem

Given a positive integer, determine whether it is perfect, abundant, or deficient.

If integers satisfy a=b×ca = b \times c, then aa is a multiple of bb and of cc, and bb and cc are divisors of aa. A proper divisor of a positive integer is any positive divisor other than the number itself (11 counts as a proper divisor; the number itself does not).

Classify a number by the sum of its proper divisors:

  • PERFECT: the sum of the proper divisors equals the number itself. For example, 6=1+2+36 = 1 + 2 + 3 and 28=1+2+4+7+1428 = 1 + 2 + 4 + 7 + 14 are perfect.
  • DEFICIENT: the sum of the proper divisors is smaller than the number. For example, the proper divisors of 99 are 1,31, 3, which sum to 44, so 99 is deficient.
  • ABUNDANT: the sum of the proper divisors is larger than the number. For example, the proper divisors of 1212 are 1,2,3,4,61, 2, 3, 4, 6, which sum to 1616, so 1212 is abundant.

Input

NN positive integers are given, separated by spaces or newlines. Each integer is at most 60,000, and 1<N<1001 < N < 100. A value of 00 marks the end of the list (00 itself is not processed).

Output

Print one line for each input integer. Each line has the form integer verdict, with a single space between the integer and the verdict. The verdict is PERFECT if the number is perfect, DEFICIENT if deficient, and ABUNDANT if abundant. Keep the same order as the input.

Examples1

  1. Example 1

    Input
    15 28 6 56 60000 22 496 0
    
    Expected output
    15 DEFICIENT
    28 PERFECT
    6 PERFECT
    56 ABUNDANT
    60000 ABUNDANT
    22 DEFICIENT
    496 PERFECT