luogu#P2657. [SCOI2009] windy 数

    ID: 1689 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划 DP搜索2009四川各省省选记忆化搜索数位 DP

[SCOI2009] windy 数

Background

The difference between this problem and P13085 [SCOI2009] windy 数(加强版) is the ranges of a\bm{a} and b\bm{b}.

Windy defined a kind of "windy number".

Problem Description

A positive integer without leading zeros, where the absolute difference between every pair of adjacent digits is at least 22, is called a windy number. Windy wants to know: between aa and bb, inclusive, how many windy numbers are there?

Input Format

The input contains a single line with two integers, representing aa and bb.

Output Format

Output a single line with one integer, the answer.

1 10
9
25 50

20

Hint

Constraints

For all test points, it is guaranteed that 1ab2×1091 \leq a \leq b \leq 2 \times 10^9.

Translated by ChatGPT 5