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
ghost_wire: 2016-06-09 05:39:39

a silly mistake cost me a lot of wrong answer... ^-^

meettaraviya: 2016-05-16 14:44:57

could anybody solve it in c++?
works for 100 randomly generated testcases, as well as testcases on spojtoolkit.com but gives WA on spojtoolkit

surya2196: 2016-03-26 21:39:04

lolypop question

sri: 2016-02-02 15:47:56

a==b
i.e 2 2
output: 2

ayush sinha: 2016-01-20 18:19:51

marvalous problem

nitin jain: 2016-01-17 21:19:54

nice problem :) learnt a lot

priyank: 2015-12-11 07:45:55

nice question :)

Prateek Agarwal: 2015-11-26 15:56:30

0.00s AC !:)

shantanu tripathi: 2015-09-01 21:18:07

nice :) learnt a new way to find sum of dig in a range

ihak: 2015-07-25 17:30:35

Digit Dynamic Programming Rocks :) Take Digit-Position as a state.


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