CPCRC1C - Sum of Digits


Majid is a 3rd-grade elementary student and quite well in mathematics. Once, Majid's teacher asked him to calculate the sum of numbers 1 through n.

Majid quickly answered, and his teacher made him another challenge. He asked Majid to calculate the sum of the digits of numbers 1 through n.

Majid did finally find the solution. Now it is your turn, can you find a solution?

Input

Two space-separated integers 0 <= a <= b <= 109.

Program terminates if a and b are -1.

Output

The sum of the digits of numbers a through b.

Example

Input:
1 10
100 777
-1 -1

Output:
46
8655

hide comments
slothsphereoj: 2024-03-21 06:00:52

[input]

1 10
100 110
100 777
0 1000000000
0 21632
1 21632
4 21634
1 22
21217 888444
2682 9836381
-1 -1

[output]

46
57
8655
40500000001
394674
394674
394699
109
23051172
308272422

aditya_1729: 2022-09-21 10:01:59

how to make our program terminate if we encounter -1,-1

vishal1019: 2022-08-21 09:42:16

AC!! First digit dp problem :)

spojian_first: 2022-07-03 12:56:15

Hello word in DigitDP

mahir_314: 2022-03-17 18:41:57

Here i have done my first digit dp problem

mahbubkuet08: 2022-03-06 19:37:35

AC after WA. Used INT instead of LONG LONG mistakenly.

Last edit: 2022-03-06 20:19:59
av1shek: 2021-07-06 11:36:33

Nice question

Last edit: 2021-07-06 16:23:34
yash_sharma115: 2021-04-26 19:01:43

Standard digit DP Problem.

Last edit: 2021-04-26 19:03:30
thinh2242005: 2021-04-10 09:44:35

hello

distructo: 2021-01-04 13:27:02

Please fill your dp with -1 two times.. I literally wasted my 4 hours because of that :(


Added by:Tii
Date:2010-10-25
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:http://cs.ikiu.ac.ir/cms/icpc/training/7-contest/86-contest1