すべてのチャレンジ
簡単 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用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。