All Tracks Algorithms Dynamic Programming Problem

Sum of Digits
Tag(s):

Algorithms, Dynamic Programming, Hard, Math

Problem
Editorial
Analytics

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

SAMPLE INPUT
5 17 5
SAMPLE OUTPUT
2
5
Time Limit: 3.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

Remember December

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?