Digit Sum Divisible

AtCoder
IDabc336_e
Time10000ms
Memory256MB
Difficulty
The **digit sum** of a positive integer $n$ is defined as the sum of the digits in the decimal notation of $n$. For example, the digit sum of $2024$ is $2+0+2+4=8$. A positive integer $n$ is called a **good integer** when $n$ is divisible by its digit sum. For example, $2024$ is a good integer because it is divisible by its digit sum of $8$. You are given a positive integer $N$. How many good integers are less than or equal to $N$? ## Constraints * $1 \leq N \leq 10^{14}$ * $N$ is an integer. ## Input The input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
20
Output #1
13

There are $13$ good integers less than or equal to $20$: $1,2,3,4,5,6,7,8,9,10,12,18,20$.
Input #2
2024
Output #2
409
Input #3
9876543210
Output #3
547452239
API Response (JSON)
{
  "problem": {
    "name": "Digit Sum Divisible",
    "description": {
      "content": "The **digit sum** of a positive integer $n$ is defined as the sum of the digits in the decimal notation of $n$. For example, the digit sum of $2024$ is $2+0+2+4=8$.   A positive integer $n$ is called ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 10000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc336_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The **digit sum** of a positive integer $n$ is defined as the sum of the digits in the decimal notation of $n$. For example, the digit sum of $2024$ is $2+0+2+4=8$.  \nA positive integer $n$ is called ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments