ง่าย 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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก