Sum of palindromic numbers
All submissions for this problem are available.
Read problems statements in Mandarin Chinese , Russian and Vietnamese
A number is called palindromic if its decimal representation is a palindrome. You are given a range, described by a pair of integers L and R. Find the sum of all palindromic numbers lying in the range [L, R], inclusive of both the extrema.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a pair of space separated integers L and R denoting the range for which you are required to find the sum of the palindromic numbers.
For each test case, output a single line containing the sum of all the palindromic numbers in the given range.
- 1 ≤ T ≤ 100
- Subtask 1 (34 points) : 1 ≤ L ≤ R ≤ 103
- Subtask 2 (66 points) : 1 ≤ L ≤ R ≤ 105
Input: 2 1 10 123 150 Output: 45 272
Example case 1. The palindromic numbers between 1 and 10 are all numbers except the number 10. Their sum is 45.
Example case 2. The palindromic numbers between 123 and 150 are 131 and 141 and their sum is 272.
|Tags||ad-hoc, ltime28, palindrome, simple, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions