Problems > The Cursed Substring

The Cursed Substring

Difficulty: 1900 3000 ms 128 MB

digit-dp

Count the integers in [L, R] whose decimal form CONTAINS the substring 13 (a 1 immediately followed by a 3).

Input: one line with two integers L and R.

Output: the count of integers containing '13'.

Constraints:

  • 1 ≤ L ≤ R ≤ 1018

Sample Tests

Input 1
1 20
Output 1
1
Input 2
13 13
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.