Problem Statement
For two positive integers a and b (a <= b) we define an integer f(a,b) as a concatenation of numbers a, a + 1, a + 2, ..., b - 1, b in a decimal notation. For example, f(2,5) = 2345, f(18,23) = 181920212223.
You are given three
Definition
- Class:
- ConcatenateNumbers
- Method:
- numberOfSegments
- Parameters:
- int, int, int
- Returns:
- long
- Method signature:
- long numberOfSegments(int L, int R, int v)
- (be sure your method is public)
Constraints
- L and R will be between 1 and 1,000,000,000 (10^9), inclusive.
- R-L will be between 0 and 100,000, inclusive.
- v should be between 0 and 1,000,000,006, inclusive.
Examples
11
13
111213
Returns: 1
f(11,11) = 11, f(11,12) = 1112, f(11,13) = 111213, f(12,12) = 12, f(12,13) = 1213, f(13,13) = 13. You must return 1 because only f(11,13) = 111213 module 1,000,000,007.
11
13
11213
Returns: 0
11
13
14
Returns: 0
1
100000
12345
Returns: 10
999900001
1000000000
0
Returns: 7
389736837
389751124
99758594
Returns: 0
17298213
17319244
412365359
Returns: 1
260209924
260219741
0
Returns: 0
220862858
220889977
541233502
Returns: 0
738003421
738006928
317412344
Returns: 1
657124599
657214169
640816009
Returns: 8
280285313
280353495
376159640
Returns: 1
219034255
219076711
104936924
Returns: 2
230091123
230126084
86889875
Returns: 3
346842131
346852370
0
Returns: 0
865105187
865205186
645903612
Returns: 3
114014850
114114849
625148805
Returns: 4
49515349
49615349
328626406
Returns: 3
252661848
252761848
700677748
Returns: 8
989647686
989747686
419754803
Returns: 8
136470734
136570734
554230306
Returns: 7
750933674
751033674
765713868
Returns: 10
678831751
678931750
901062254
Returns: 5
814368591
814468591
541667921
Returns: 9
403764394
403864394
900757432
Returns: 4
999999999
1000000000
553
Returns: 1