6747.Counting Numbers

Time Limit: 1s Memory Limit: 512MB

Your task is to count the number of integers between $a$ and $b$ where no two adjacent digits are the same.

Input Format(From the terminal/stdin)

The only input line has two integers $a$ and $b$ .

  • $0 \le a \le b \le 10^{18}$

Output Format(To the terminal/stdout)

Print one integer: the answer to the problem.

Sample Input

Copy
123 321
   ·   \n

Sample Output

Copy
171
   \n
Source: CSES, Dynamic Programming, 2220

Submit

请先 登录

© 2025 FAQs