CR08C3P5 - CUDAK
Božo 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 Božo's question so that he can get some sleep.
Input
The input contains three integers A, B and S (1 ≤ A ≤ B < 1015, 1 ≤ S ≤ 135).
Output
The first line should contain the number of integers in the interval with the digit sum equal to S. The second line should contain the smallest such integer. The input data will guarantee that the first number is at least 1.
Example
Input: 1 9 5 Output: 1
5
Input:
1 100 10 Output:
9
19
Input:
11111 99999 24 Output:
5445
11499
Added by: | Ahmed Salem [mrtempo] |
Date: | 2015-01-31 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | COCI 2007/2008 #3 (http://hsin.hr/coci/archive/2007_2008/contest3_tasks.pdf) |