#B3786. Lucky Number Count
Lucky Number Count
Lucky Number Count
A lucky number is defined as a number whose odd-position digits sum is equal to the even-position digits sum, when the number is represented in decimal. Positions are counted from left to right starting at 1.
For example:
- For
12345
, the digits at odd positions are 1, 3, and 5, whose sum is \(1+3+5=9\); the digits at even positions are 2 and 4, whose sum is \(2+4=6\). Since \(9 \neq 6\), 12345 is not a lucky number. - For
2332
, the digits at odd positions are 2 and 3, whose sum is \(2+3=5\); the digits at even positions are 3 and 2, whose sum is \(3+2=5\). Since \(5 = 5\), 2332 is a lucky number.
Given two integers \(a\) and \(b\), count the number of lucky numbers in the range \([a, b]\) (inclusive).
inputFormat
The input consists of a single line containing two space-separated integers \(a\) and \(b\) \((1 \leq a \leq b \leq 10^9)\).
outputFormat
Output a single integer representing the count of lucky numbers in the range \([a, b]\).
sample
12345 12345
0