Connection Status:
Competition Arena > Dubs
SRM 692 · 2016-06-04 · by Xellos0 · Brute Force
Class Name: Dubs
Return Type: long
Method Name: count
Arg Types: (long long, long long)
Problem Statement

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.

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
0)
113464799236
699002764401
Returns: 58553796517

random

1)
501346554765
950073613017
Returns: 44872705826

random

2)
48376858957
220792504052
Returns: 17241564509

random

3)
101337192990
378858372907
Returns: 27752117992

random

4)
38545321940
106671028225
Returns: 6812570629

random

5)
124611151838
239397661677
Returns: 11478650984

random

6)
138547834386
232307426991
Returns: 9375959261

random

7)
47125899421
191084480726
Returns: 14395858131

random

8)
82895970282
175876717732
Returns: 9298074745

random

9)
923003927863
998207498364
Returns: 7520357050

random

10)
10
10
Returns: 0

The only number in the range [10,10] is 10. It isn't a double number.

13)
10
20
Returns: 1

The only double number in the range [10,20] is 11.

15)
49
101
Returns: 6

The double numbers are 55, 66, 77, 88, 99 and 100.

34)
47
53
Returns: 0

zero

35)
826611854162
826611854164
Returns: 0

zero

36)
888888888883
888888888883
Returns: 0

zero

37)
688390061801
688390061810
Returns: 0

zero

Submissions are judged against all 56 archived test cases, of which 17 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class Dubs with a public method long long count(long long L, long long R) · 56 test cases · 2 s / 256 MB per case

Submitting as anonymous