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.
Definition
- Class:
- LittleElephantAndArray
- Method:
- getNumber
- Parameters:
- long, int
- Returns:
- int
- Method signature:
- int getNumber(long A, int N)
- (be sure your method is public)
Constraints
- A will be between 1 and 1,000,000,000,000,000 (10^15), inclusive.
- N will be between 0 and 100, inclusive.
Examples
1
9
Returns: 1
10
2
Returns: 15
4747774
1
Returns: 8369
6878542150015
74
Returns: 977836619
1000000000000000
100
Returns: 22435455
458975015421547
100
Returns: 959658342
1
0
Returns: 1
7
100
Returns: 1
4584
99
Returns: 723792987
698458458
47
Returns: 865110940
999999
100
Returns: 832160019
999999999999999
99
Returns: 726682887
999999999999
1
Returns: 9736590
174094882455171
47
Returns: 820811374
152761423221685
99
Returns: 626576399
761892795431233
99
Returns: 3096955
411387427793198
100
Returns: 380569836
650286024865090
100
Returns: 297459252
61389344606618
100
Returns: 966356191
49637882913598
100
Returns: 196396154
4
100
Returns: 1
76361542097372
0
Returns: 16383
601657541200146
7
Returns: 937030068
71777733599818
2
Returns: 109835302
266038012509478
1
Returns: 536875419
351201640618984
25
Returns: 801343434
143988087783837
97
Returns: 234890512
107349651099683
100
Returns: 476141741
4849925
74
Returns: 236923574
53337438088
79
Returns: 751395306
6819897228
100
Returns: 684345262
28907815861
100
Returns: 175903871
24258626539
99
Returns: 649350618
24618211976
98
Returns: 762873461
295200391819
100
Returns: 573358811
5325258677229
100
Returns: 184495288
4196982554
100
Returns: 279812471
9125083
75
Returns: 569602429
99999875099999
100
Returns: 181093175
1000000000000000
2
Returns: 734978268
687852150022153
87
Returns: 603846919