Problems > Numbers That Only Climb

Numbers That Only Climb

Difficulty: 1700 3000 ms 128 MB

digit-dp

Count the integers in [L, R] whose digits are non-decreasing left to right (like 1358).

Input: one line with two integers L and R.

Output: the count of qualifying integers in [L, R].

Constraints:

  • 1 ≤ L ≤ R ≤ 1018

Sample Tests

Input 1
1 30
Output 1
26
Input 2
100 200
Output 2
45

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.