Sum of Digits
Practice
4.1 (14 votes)
Dynamic programming
Hard
Algorithms
Mathematics
Open
Approved
Problem
64% Success 4186 Attempts 50 Points 3s Time Limit 256MB Memory 1024 KB Max Code
The problems is to find the count of numbers between A and B (inclusive) that have sum of digits equal to S.
Also print the smallest such number between A and B (inclusive).
Input:
Single line consisting of A,B,S.
Output:
Two lines.
In first line the number of integers between A and B having sum of digits equal to S.
In second line the smallest such number between A and B.
Constraints:
1 <= A <= B < 10^15
1 <= S <= 135
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
9 votes
Tags:
Dynamic ProgrammingAlgorithmsC++
Points:50
2 votes
Tags:
AlgorithmsDynamic ProgrammingBinary SearchNumber theory
3.Kth path
Points:50
2 votes
Tags:
HardAlgorithmsApproved
Editorial
Login to unlock the editorial