#C10037. Count Palindromic Numbers

    ID: 39198 Type: Default 1000ms 256MiB

Count Palindromic Numbers

Count Palindromic Numbers

You are given a range of integers \(L\) and \(R\) (inclusive) and you are required to count all palindromic numbers within this range.

A number \(n\) is considered palindromic if its decimal representation reads the same backward as forward. In other words, if \(n\) is represented as \(d_0d_1\cdots d_k\), then for all \(i\) with \(0 \le i \le k\), we must have \(d_i = d_{k-i}\). For example, \(121\) and \(12321\) are palindromic, while \(123\) is not.

Your task is to implement a function that, given several test cases, returns the count of palindromic numbers in the specified range for each test case.

inputFormat

The first line of the input contains a single integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains two space-separated integers \(L\) and \(R\) representing the inclusive bounds of the range.

Example:

2
1 10
11 20

outputFormat

For each test case, output a single line containing the count of palindromic numbers in the given range.

Example:

9
1
## sample
2
1 10
11 20
9

1

</p>