Digits Parade

AtCoder
IDabc135_d
Time2000ms
Memory256MB
Difficulty
Given is a string $S$. Each character in $S$ is either a digit (`0`, ..., `9`) or `?`. Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of $5$ when divided by $13$? An integer may begin with $0$. Since the answer can be enormous, print the count modulo $10^9+7$. ## Constraints * $S$ is a string consisting of digits (`0`, ..., `9`) and `?`. * $1 \leq |S| \leq 10^5$ ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
??2??5
Output #1
768

For example, $482305, 002865,$ and $972665$ satisfy the condition.
Input #2
?44
Output #2
1

Only $044$ satisfies the condition.
Input #3
7?4
Output #3
0

We may not be able to produce an integer satisfying the condition.
Input #4
?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???
Output #4
153716888
API Response (JSON)
{
  "problem": {
    "name": "Digits Parade",
    "description": {
      "content": "Given is a string $S$. Each character in $S$ is either a digit (`0`, ..., `9`) or `?`. Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of $5$ wh",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc135_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a string $S$. Each character in $S$ is either a digit (`0`, ..., `9`) or `?`.\nAmong the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of $5$ wh...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments