Interesting Numbers
Time limit1sMemory limit512 MB
Count positive integers between L and R whose decimal digits are nondecreasing, modulo 1e9+7, with L and R up to 10^100.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Implementation
- Solved
- No attempts yet
Problem
Sofia considers a number interesting if its digits are in nondecreasing order. For example, 123, 1111, and 888999 are interesting.
Sofia wonders how many interesting positive integers lie in the range from to inclusive. For large and this count can be quite large, so Sofia wants the remainder of this count modulo .
Write a program that, given and , determines the number of interesting numbers in the range from to inclusive and prints the remainder of this count modulo .
Input
The input file contains two lines. The first line contains the number , and the second line contains the number ().
Output
The output file must contain a single integer: the remainder of the number of interesting numbers in the range from to inclusive modulo .