137. Cheesy Numbers

Codeforces
IDCF10269137
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You consider a number to be _cheesy_ if it is divisible by the sum of its digits. For example, the sum of the digits of 360 is 9, and 360 is divisible by 9, so 360 is a _cheesy number_. On the other hand, the sum of digits of 87 is 15, and 87 is not divisible by 15, so 87 is not a _cheesy number_. Given a number $n$, figure out whether or not it is a cheesy number. The only line of input contains a single integer $n$: the number to test. $n$ is guaranteed to fit inside of an "int" data type in Java. If $n$ is a _cheesy number_ as described above, output "YES" (no quotes). Otherwise, output "NO" (no quotes). ## Input The only line of input contains a single integer $n$: the number to test. $n$ is guaranteed to fit inside of an "int" data type in Java. ## Output If $n$ is a _cheesy number_ as described above, output "YES" (no quotes). Otherwise, output "NO" (no quotes). [samples]
**Definitions** Let $ n \in \mathbb{Z} $ be the input integer. Let $ s(n) = \sum_{d \in \text{digits}(n)} d $ denote the sum of the decimal digits of $ n $. **Constraints** $ n $ fits in a Java `int` (i.e., $ -2^{31} \leq n \leq 2^{31} - 1 $). **Objective** Determine whether $ s(n) \mid n $. If true, output "YES"; otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "137. Cheesy Numbers",
    "description": {
      "content": "You consider a number to be _cheesy_ if it is divisible by the sum of its digits. For example, the sum of the digits of 360 is 9, and 360 is divisible by 9, so 360 is a _cheesy number_. On the other h",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269137"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You consider a number to be _cheesy_ if it is divisible by the sum of its digits. For example, the sum of the digits of 360 is 9, and 360 is divisible by 9, so 360 is a _cheesy number_. On the other h...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the input integer.  \nLet $ s(n) = \\sum_{d \\in \\text{digits}(n)} d $ denote the sum of the decimal digits of $ n $.\n\n**Constraints**  \n$ n $ fits in a Java...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments