A sequence of digits usually represents a number, but another interpretation is possible. This problem defines a new order relation ≺ between digit sequences of the same length.
Let s=d1d2⋯dn be a sequence of n digits, where each di (1≤i≤n) is one of 0,1,…,9. Define sum(s), prod(s), and int(s) as follows.
- sum(s)=d1+d2+⋯+dn
- prod(s)=(d1+1)×(d2+1)×⋯×(dn+1)
- int(s)=d1×10n−1+d2×10n−2+⋯+dn×100
int(s) is the integer that the sequence s represents under the usual decimal reading.
For two sequences s1 and s2 of the same length, s1≺s2 (s1 is less than s2) holds if and only if one of the following three conditions holds.
- sum(s1)<sum(s2)
- sum(s1)=sum(s2) and prod(s1)<prod(s2)
- sum(s1)=sum(s2), prod(s1)=prod(s2), and int(s1)<int(s2)
For sequences of length 2, the order runs like this.
00≺01≺10≺02≺20≺11≺03≺30≺12≺21≺⋯≺89≺98≺99
Given a sequence s of n digits, count the sequences of n digits that are less than s under the order ≺ defined above.