LittleElephantAndArray
SRM 592 · 2013-06-25 · by Witaliy
Problem Statement
Little Elephant from the Zoo of Lviv likes sequences of integers.
You are given a
It is allowed for some number to contain leading zeroes after erasings. For example, from the number 1047 Little Elephant may create, among other possibilities, the number 047 or the number 47. These are two different ways of erasing. They are both allowed and the numbers they produce have the same value.
Two ways of erasing the digits are considered different if there is some position in some element of S that was erased in one of the cases and was not erased in the other one. For example, if S = (11, 12), there are two different ways to change it to (1, 2). (In one of them we erase the first and in the other we erase the second digit of the number 11.)
After erasing the digits, Little Elephant wants to obtain a non-decreasing sequence. Let R be the number of different ways to do that. Return R modulo 1,000,000,007.
Constraints
- A will be between 1 and 1,000,000,000,000,000 (10^15), inclusive.
- N will be between 0 and 100, inclusive.
1 9 Returns: 1
10 2 Returns: 15
4747774 1 Returns: 8369
6878542150015 74 Returns: 977836619
1000000000000000 100 Returns: 22435455
Submissions are judged against all 41 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class LittleElephantAndArray with a public method int getNumber(long long A, int N) · 41 test cases · 2 s / 256 MB per case