Ascending Numbers
InterviewTime limit1sMemory limit256 MB
Count length-N digit strings, leading zeros allowed, whose digits never decrease left to right, modulo 10007.
- Level
Easy3 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
An ascending number is a number whose digits never decrease from left to right. Two adjacent digits that are equal still count as ascending.
For example, 2234, 3678, and 11119 are ascending numbers, while 2232, 3676, and 91111 are not.
Given the length , write a program that counts the ascending numbers of length . The leading digit may be 0.
Input
The first line contains . ()
Output
Print the number of ascending numbers of length , modulo , on the first line.