TopcoderArchiveVisit Topcoder
SRM4 Jun 2016
SRM 692

Dubs

Problem statement, definition, constraints, and public examples.

Problem Statement

A positive integer X is called a double number if its decimal representation (without leading zeroes) has the following properties:

  • it contains at least two digits
  • the two least significant digits are identical

For example, 1488 is a double number, but 3 and 221 are not.


You are given two longs: L and R. Compute how many double numbers lie between L and R, inclusive. Return their count.

Definition

Class:
Dubs
Method:
count
Parameters:
long, long
Returns:
long
Method signature:
long count(long L, long R)
(be sure your method is public)

Constraints

  • L will be between 10 and 1,000,000,000,000 (10^12), inclusive.
  • R will be between L and 1,000,000,000,000 (10^12), inclusive.

Examples

  1. 10
    10
    Returns: 0
    The only number in the range [10,10] is 10. It isn't a double number.
  2. 10
    20
    Returns: 1
    The only double number in the range [10,20] is 11.
  3. 49
    101
    Returns: 6
    The double numbers are 55, 66, 77, 88, 99 and 100.
  4. 1111111
    111111111
    Returns: 11000001
  5. 91750002841
    91751522033
    Returns: 151920
Back to all problems