#CCBOTPBA0000060. Đếm số đối xứng trong đoạn (Count Palindromic Numbers in an Interval)
Đếm số đối xứng trong đoạn (Count Palindromic Numbers in an Interval)
Count Palindromic Numbers in an Interval
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A non-negative integer is palindromic if its decimal digits read the same left to right and right to left. For example, , , , and are palindromic, but and are not. Given integers and with , count palindromic integers in the inclusive interval . Zero is palindromic.
Input
One line contains two integers and , in this order.
Output
Print one integer: the count of palindromic integers in .
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input:
0 11
Output:
11
Explanation: The ten values 0 through 9 are palindromic. 10 is not; 11 is. Therefore the total is 10 + 1 = 11.
Example 2
Input:
120 123
Output:
1
Explanation: Reversing 120, 121, 122 and 123 gives 21, 121, 221 and 321. Only 121 is palindromic, so the answer is 1.
Example 3
Input:
0 0
Output:
1
Explanation: The interval contains only zero, whose single digit is unchanged when reversed. The answer is 1.