TopCoder problem "SumThemAll" used in SRM 311 (Division I Level Two)



Problem Statement

    

Find the sum of all the digits in all the integers between lowerBound and upperBound, inclusive.

 

Definition

    
Class:SumThemAll
Method:getSum
Parameters:int, int
Returns:long
Method signature:long getSum(int lowerBound, int upperBound)
(be sure your method is public)
    
 

Constraints

-upperBound will be between 0 and 2,000,000,000, inclusive.
-lowerBound will be between 0 and upperBound, inclusive.
 

Examples

0)
    
0
3
Returns: 6
0 + 1 + 2 + 3 = 6
1)
    
10
14
Returns: 15
(1+0) + (1+1) + (1+2) + (1+3) + (1+4) = 15
2)
    
0
0
Returns: 0
3)
    
14
53
Returns: 296
4)
    
24660
308357171
Returns: 11379854844

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=6430

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=9991&pm=6430

Writer:

gevak

Testers:

PabloGilberto , brett1479 , Olexiy , Andrew_Lazarev

Problem categories:

Dynamic Programming