Tất cả thử thách
Dễ 0 đã giải Tỷ lệ chấp nhận 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.

Ràng buộc

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

Ví dụ

Ví dụ 1
Đầu vào:
n = 18

Kết quả mong đợi:
expected = "abundant"
Đầu vào:
long long n = 18;

Kết quả mong đợi:
std::string expected = "abundant";
Đầu vào:
long n = 18;

Kết quả mong đợi:
string expected = "abundant";

Giải thích

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

Ví dụ 2
Đầu vào:
n = 28

Kết quả mong đợi:
expected = "perfect"
Đầu vào:
long long n = 28;

Kết quả mong đợi:
std::string expected = "perfect";
Đầu vào:
long n = 28;

Kết quả mong đợi:
string expected = "perfect";

Giải thích

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

Tham khảo

Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.

Học hỏi từ người khác

Giải pháp cộng đồng

Chưa có giải pháp nào được chia sẻ. Hãy giải thử thách này để đăng giải pháp đầu tiên.