ConcatenateNumbers
TCO 2014 Celebrity Match · 2014-03-26 · by Vasyl[alphacom]
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
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.
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
Submissions are judged against all 26 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ConcatenateNumbers with a public method long long numberOfSegments(int L, int R, int v) · 26 test cases · 2 s / 256 MB per case