Gaurav and Sum

3.1

7 votes
Medium-Hard
Problem

Statement

Gaurav is a strange little boy. Every day he tires his friends with strange questions. Today's question is:

How many integers in the interval [A,B] are there such that the sum of their digits is S, and which is the smallest such number?

Write a program that answers Gaurav's question so that he can get some sleep.

Input

  • First and only line of input contains three integers A,B,S.

Output

  • First line of output should contain a single integer denoting the number of integers in range [A,B] having digit sum S
  • Second line of output contains single integer, the smallest number in the range [A,B] having digit sum S.

Constraints

  • 1AB1015
  • 1S135
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?