138. Perfect Numbers

Codeforces
IDCF10269138
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
A number is considered a _perfect number_ if and only if the sum of its divisors, except for the number itself, is equal to the original number. For example, 28 is a _perfect number_ because its divisors are $1$, $2$, $4$, $7$, and $14$, and $1$ + $2$ + $4$ + $7$ + $14$ = $28$. Given an integer $n$, figure out whether or not it is a perfect number, and what the sum of its divisors (except for $n$) is. The only line of input consists of a single integer $n$. Output two lines. On the first line, output "PERFECT NUMBER" (no quotes) if the number is a perfect number, and "NOT A PERFECT NUMBER" (no quotes) if the number is not a perfect number. On the second line, output the sum of divisors of the number. All numbers used in calculations are guaranteed to fit inside of a Java "int" data type. ## Input The only line of input consists of a single integer $n$. ## Output Output two lines.On the first line, output "PERFECT NUMBER" (no quotes) if the number is a perfect number, and "NOT A PERFECT NUMBER" (no quotes) if the number is not a perfect number. On the second line, output the sum of divisors of the number. [samples] ## Note All numbers used in calculations are guaranteed to fit inside of a Java "int" data type.
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the input integer. Let $ D(n) = \{ d \in \mathbb{Z}^+ \mid d \mid n \text{ and } d < n \} $ be the set of proper positive divisors of $ n $. Let $ \sigma(n) = \sum_{d \in D(n)} d $ be the sum of the proper divisors of $ n $. **Constraints** $ 1 \leq n \leq 2^{31} - 1 $ (fits in a Java `int`) **Objective** Compute $ \sigma(n) $. Output: - First line: "PERFECT NUMBER" if $ \sigma(n) = n $, otherwise "NOT A PERFECT NUMBER". - Second line: $ \sigma(n) $.
API Response (JSON)
{
  "problem": {
    "name": "138. Perfect Numbers",
    "description": {
      "content": "A number is considered a _perfect number_ if and only if the sum of its divisors, except for the number itself, is equal to the original number. For example, 28 is a _perfect number_ because its divis",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269138"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A number is considered a _perfect number_ if and only if the sum of its divisors, except for the number itself, is equal to the original number. For example, 28 is a _perfect number_ because its divis...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the input integer.  \nLet $ D(n) = \\{ d \\in \\mathbb{Z}^+ \\mid d \\mid n \\text{ and } d < n \\} $ be the set of proper positive divisors of $ n $.  \nLet $ \\...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments