atcoder#WTF19B. Multiple of Nine
Multiple of Nine
Score : points
Problem Statement
Count the number of strings that satisfy the following constraints, modulo .
- The length of is exactly .
- consists of digits (
0
...9
). - You are given intervals. For each , the integer represented by (the substring of between the -th (-based) character and the -th character, inclusive) must be a multiple of .
Here, the string and its substrings may have leading zeroes.
For example, 002019
represents the integer .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of strings that satisfy the conditions, modulo .
4
2
1 2
2 4
136
For example, 9072
satisfies the conditions because both 90
and 072
represent multiples of .
6
3
2 5
3 5
1 3
2720
20
10
2 15
5 6
1 12
7 9
2 17
5 15
2 4
16 17
2 12
8 17
862268030