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 ints L, R, v. Return the number of pairs of integers x, y (L <= x <= y <= R) such that f(x,y) is equal to v modulo 1,000,000,007.
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