Connection Status:
Competition Arena > SumThemAll
SRM 311 · 2006-07-12 · by gevak · Dynamic Programming
Class Name: SumThemAll
Return Type: long
Method Name: getSum
Arg Types: (int, int)
Problem Statement

Problem Statement

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

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)
0
2000000000
Returns: 82000000002

Submissions are judged against all 47 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class SumThemAll with a public method long long getSum(int lowerBound, int upperBound) · 47 test cases · 2 s / 256 MB per case

Submitting as anonymous