Almost Everywhere Zero

AtCoder
IDabc154_e
Time2000ms
Memory256MB
Difficulty
Find the number of integers between $1$ and $N$ (inclusive) that contains exactly $K$ non-zero digits when written in base ten. ## Constraints * $1 \leq N < 10^{100}$ * $1 \leq K \leq 3$ ## Input Input is given from Standard Input in the following format: $N$ $K$ [samples]
Samples
Input #1
100
1
Output #1
19

The following $19$ integers satisfy the condition:

*   $1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100$
Input #2
25
2
Output #2
14

The following $14$ integers satisfy the condition:

*   $11,12,13,14,15,16,17,18,19,21,22,23,24,25$
Input #3
314159
2
Output #3
937
Input #4
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
3
Output #4
117879300
API Response (JSON)
{
  "problem": {
    "name": "Almost Everywhere Zero",
    "description": {
      "content": "Find the number of integers between $1$ and $N$ (inclusive) that contains exactly $K$ non-zero digits when written in base ten.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc154_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Find the number of integers between $1$ and $N$ (inclusive) that contains exactly $K$ non-zero digits when written in base ten.\n\n## Constraints\n\n*   $1 \\leq N < 10^{100}$\n*   $1 \\leq K \\leq 3$\n\n## Inp...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments