모든 챌린지
쉬움 0명 해결 정답률 0%

Classify a Number by Its Divisors

Classify a positive integer as perfect, abundant, or deficient.

Add the positive divisors of n that are strictly smaller than n. If their sum equals n, the number is perfect. If the sum is larger, it is abundant; if smaller, it is deficient. The number 1 has no proper positive divisors, so its divisor sum is 0.

Implement perfect_number(n).

Input

n: The positive integer to classify.

Output

Return perfect, abundant, or deficient as lowercase text.

제약 조건

1 ≤ n ≤ 1,000,000. Zero and negative values are excluded.

예시

예시 1
입력:
n = 18

예상 출력:
expected = "abundant"
입력:
long long n = 18;

예상 출력:
std::string expected = "abundant";
입력:
long n = 18;

예상 출력:
string expected = "abundant";

설명

The proper divisors are 1, 2, 3, 6, and 9. Their sum is 21, greater than 18.

예시 2
입력:
n = 28

예상 출력:
expected = "perfect"
입력:
long long n = 28;

예상 출력:
std::string expected = "perfect";
입력:
long n = 28;

예상 출력:
string expected = "perfect";

설명

The proper divisors sum to 1 + 2 + 4 + 7 + 14 = 28, exactly the number itself.

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.