Connection Status:
Competition Arena > ConcatenateNumbers
TCO 2014 Celebrity Match · 2014-03-26 · by Vasyl[alphacom] · Math, Recursion
Class Name: ConcatenateNumbers
Return Type: long
Method Name: numberOfSegments
Arg Types: (int, int, int)
Problem Statement

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.

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
0)
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.

1)
11
13
11213
Returns: 0
2)
11
13
14
Returns: 0
3)
1
100000
12345
Returns: 10
4)
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.

Coding Area

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

Submitting as anonymous