PR003004  Digit Sum
For a pair of integers a and b, the digit sum of the interval [a,b] is defined as the sum of all digits occurring in all numbers between (and including) a and b. For example, the digit sum of [28, 31] can be calculated as:
2+8 + 2+9 + 3+0 + 3+1 = 28
Given the numbers a and b, calculate the digit sum of [a,b].
Input
On the first line one positive number: the number of test cases, at most 100.
After that per test case:
 one line with two spaceseparated integers, a and b (0 <= a <= b <= 10^15).
Output
Per test case:
 one line with an integer: the digit sum of [a,b];
Example
Input: 3 0 10 28 31 1234 56789 Output: 46 28 1128600
hide comments
fuadul_hasan:
20220825 08:05:45
easy one. :)


ajju_1209:
20220815 18:02:03
can someone tell me if i use vector of vector as dp table it gives wa but if i use global 2d array it gives ac why?


ayanv:
20220308 18:03:38
@dwij28 I had the same problem when I found that I was unintentionally converting long long int into int . Maybe you have the same problem in your code. I tried solving for 10^15 and the output was coming out to be zero, you can also try for the same value.


rangey_18o3_20:
20210827 17:58:40
Unsigned Long Long for the wins


av1shek:
20210706 11:36:58
getting wrong answer on using long long in c++ Last edit: 20210706 16:37:45 

av1shek:
20210706 11:35:03
@dwij28 instead of long long, use unsigned long long int 

codeman98:
20210429 19:44:29
Getting wrong answer.


abhishen99:
20201224 13:15:36
easy peasy ... 

vyavaharesid:
20200520 16:13:01
can anyone help me iam getting tle tried code of gfg digit sum plz give any link for studying 

rul0:
20200209 20:05:37
this problem have something rare. I have the same situation as dwij28, 3 comments below 
Added by:  kojak_ 
Date:  20131125 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  BAPC 