Problem Statement
Little Elephant from the Zoo of Lviv has a set S. The set S contains the integers 1, 2, 3, ..., N. He considers some non-empty subset of S cool if we can write down all elements of the subset by using each of the digits 0-9 at most once.
Examples: The subsets {12,345,67890} and {47,109} are cool. The subset {147,342} is not cool because the digit 4 is used twice. The subset {404} is not cool for the same reason.
You are given the
Definition
- Class:
- LittleElephantAndSubset
- Method:
- getNumber
- Parameters:
- int
- Returns:
- int
- Method signature:
- int getNumber(int N)
- (be sure your method is public)
Constraints
- N will be between 1 and 1,000,000,000 (10^9), inclusive.
Examples
3
Returns: 7
All 7 non-empty subsets are cool in this case: {1, 2, 3} {1, 2} {1, 3} {2, 3} {1} {2} {3}
10
Returns: 767
In this case, the total number of non-empty subsets is 2^10-1 = 1023. The only not cool subsets are those that contain both 1 and 10. There are 2^8 = 256 of them. Thus, the answer is 1023-256 = 767.
47
Returns: 25775
4777447
Returns: 66437071
1000000000
Returns: 88291951
1
Returns: 1
7
Returns: 127
999999999
Returns: 88291951
100000001
Returns: 82122991
777777777
Returns: 86769871
474747474
Returns: 84676111
883
Returns: 5821431
153
Returns: 613623
222
Returns: 844479
893
Returns: 5895791
234
Returns: 861303
428
Returns: 1821447
651
Returns: 3447559
24866
Returns: 27503839
61390
Returns: 35897155
6619
Returns: 17076727
78830
Returns: 39888079
84077
Returns: 41330863
42098
Returns: 31520311
1658
Returns: 8228067
1200147
Returns: 61613551
1777734
Returns: 62445391
9818267
Returns: 73308751
8012510
Returns: 70753791
8351202
Returns: 71294471
618985
Returns: 54575911
3988088
Returns: 65430511
783837108
Returns: 86806711
349651100
Returns: 83798083
683484993
Returns: 86118415
553337439
Returns: 85247791
88068199
Returns: 81049471
972282891
Returns: 88162951
781586125
Returns: 86786455
258626540
Returns: 83178607
246182120
Returns: 83080807
762952004
Returns: 86722729
918195326
Returns: 87754831
258677230
Returns: 83179213
419698256
Returns: 84332911
491250840
Returns: 84801167
19
Returns: 1791
1000000
Returns: 61438831
13
Returns: 1023
100000000
Returns: 82122991
14
Returns: 1151
999999998
Returns: 88291951
907014377
Returns: 87666991
16
Returns: 1407
713526152
Returns: 86340133