Problem Statement
You have a digital display with an infinite number of positions. Each position consists of 7 segments - 4 vertical and 3 horizontal. Lighting certain segments within a position allows you to represent different decimal digits on the display:
You can use the display to represent different non-negative integers. To represent an integer you need to show its digits, in order, on consecutive display positions. The integers you represent on the display cannot have extra leading zeros.
You are given an
Definition
- Class:
- SegmentDisplay
- Method:
- howManyNumbers
- Parameters:
- int
- Returns:
- int
- Method signature:
- int howManyNumbers(int n)
- (be sure your method is public)
Constraints
- n will be between 0 and 500000, inclusive.
Examples
2
Returns: 1
Using 2 segments you can represent an integer 1.
1
Returns: 0
One segment is not enough to display even one digit.
6
Returns: 7
Using 6 segments you can represent integers 0, 6, 9, 14, 41, 77, 111.
10
Returns: 59
0
Returns: 0
132
Returns: 316551649
1234
Returns: 784891370
480
Returns: 349710798
43092
Returns: 303482407
23456
Returns: 458113089
50000
Returns: 208262111
49999
Returns: 411010332
49998
Returns: 585239692
30000
Returns: 437894589
4321
Returns: 748782060
7139
Returns: 837106957
8430
Returns: 470591483
23094
Returns: 202063093
48130
Returns: 854522348
13872
Returns: 855193772
38123
Returns: 211161181
3719
Returns: 450030610
8310
Returns: 712665333
500000
Returns: 138757250
499999
Returns: 872544874
74298
Returns: 766298829
482092
Returns: 453446804
238091
Returns: 578896893
132312
Returns: 485107853
111111
Returns: 402461183
123456
Returns: 580882242
432101
Returns: 271982362
389121
Returns: 767810115
64328
Returns: 359709827
74932
Returns: 598600155
78421
Returns: 461193820
238291
Returns: 106222222
3
Returns: 1
4
Returns: 2
5
Returns: 5
7
Returns: 12
8
Returns: 19
9
Returns: 33
499999
Returns: 872544874
499998
Returns: 59869508
497997
Returns: 874697853
450000
Returns: 187652507