Statistics

Problem Statement for "ConcatenateNumbers"

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

  1. 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.

  2. 11

    13

    11213

    Returns: 0

  3. 11

    13

    14

    Returns: 0

  4. 1

    100000

    12345

    Returns: 10

  5. 999900001

    1000000000

    0

    Returns: 7

  6. 389736837

    389751124

    99758594

    Returns: 0

  7. 17298213

    17319244

    412365359

    Returns: 1

  8. 260209924

    260219741

    0

    Returns: 0

  9. 220862858

    220889977

    541233502

    Returns: 0

  10. 738003421

    738006928

    317412344

    Returns: 1

  11. 657124599

    657214169

    640816009

    Returns: 8

  12. 280285313

    280353495

    376159640

    Returns: 1

  13. 219034255

    219076711

    104936924

    Returns: 2

  14. 230091123

    230126084

    86889875

    Returns: 3

  15. 346842131

    346852370

    0

    Returns: 0

  16. 865105187

    865205186

    645903612

    Returns: 3

  17. 114014850

    114114849

    625148805

    Returns: 4

  18. 49515349

    49615349

    328626406

    Returns: 3

  19. 252661848

    252761848

    700677748

    Returns: 8

  20. 989647686

    989747686

    419754803

    Returns: 8

  21. 136470734

    136570734

    554230306

    Returns: 7

  22. 750933674

    751033674

    765713868

    Returns: 10

  23. 678831751

    678931750

    901062254

    Returns: 5

  24. 814368591

    814468591

    541667921

    Returns: 9

  25. 403764394

    403864394

    900757432

    Returns: 4

  26. 999999999

    1000000000

    553

    Returns: 1


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: