#P1831. 杠杆数

杠杆数

Description

If we take one digit of a number as the fulcrum, and the sum of the moments of the digits to the left about this point equals the sum of the moments of the digits to the right about this point, then the number is called a lever number.

For example, 41394139 is a lever number. Taking 33 as the fulcrum, we have the equation: 4×2+1×1=9×14 \times 2 + 1 \times 1 = 9 \times 1.

Given the interval [x,y][x,y], find how many lever numbers are in [x,y][x,y].

Input Format

Two integers, x,yx,y.

Output Format

A single integer, the number of lever numbers in the interval [x,y][x,y].

7604 24324
897

Hint

Constraints

  • For 40%40\% of the testdata, xyx+105x \le y \le x + 10^5.
  • For 100%100\% of the testdata, 1xy10181 \le x \le y \le 10^{18}.

Translated by ChatGPT 5